class Dbee::Query::Filters::Base

Defines the shared implementation for all filters.

Attributes

key_path[R]
value[R]

Public Class Methods

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

  @key_path = KeyPath.get(key_path)
  @value    = value

  freeze
end

Public Instance Methods

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