class Dbee::Query::Sorters::Base

Abstract representation of the ORDER BY part of a SQL statement.

Attributes

key_path[R]

Public Class Methods

new(key_path:) click to toggle source
# File lib/dbee/query/sorters/base.rb, line 19
def initialize(key_path:)
  raise ArgumentError, 'key_path is required' if key_path.to_s.empty?

  @key_path = KeyPath.get(key_path)

  freeze
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/dbee/query/sorters/base.rb, line 37
def <=>(other)
  "#{key_path}#{self.class.name}" <=> "#{other.key_path}#{other.class.name}"
end
==(other) click to toggle source
# File lib/dbee/query/sorters/base.rb, line 31
def ==(other)
  other.instance_of?(self.class) &&
    other.key_path == key_path
end
Also aliased as: eql?
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/dbee/query/sorters/base.rb, line 27
def hash
  "#{self.class.name}#{key_path}".hash
end