Class: Dbee::Query::Filters::Base
- Inherits:
-
Object
- Object
- Dbee::Query::Filters::Base
- Defined in:
- lib/dbee/query/filters/base.rb
Overview
Defines the shared implementation for all filters.
Direct Known Subclasses
Contains, Equals, GreaterThan, GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo, NotContain, NotEquals, NotStartWith, StartsWith
Instance Attribute Summary collapse
-
#key_path ⇒ Object
readonly
Returns the value of attribute key_path.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(key_path:, value: nil) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(key_path:, value: nil) ⇒ Base
Returns a new instance of Base.
19 20 21 22 23 24 25 26 |
# 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 |
Instance Attribute Details
#key_path ⇒ Object (readonly)
Returns the value of attribute key_path.
17 18 19 |
# File 'lib/dbee/query/filters/base.rb', line 17 def key_path @key_path end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
17 18 19 |
# File 'lib/dbee/query/filters/base.rb', line 17 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
39 40 41 42 |
# 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) ⇒ Object Also known as: eql?
32 33 34 35 36 |
# 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 |
#hash ⇒ Object
28 29 30 |
# File 'lib/dbee/query/filters/base.rb', line 28 def hash "#{self.class.name}#{key_path}#{value}".hash end |