Class: ActiveAny::Relation::WhereClause::Condition
- Inherits:
-
Object
- Object
- ActiveAny::Relation::WhereClause::Condition
- Defined in:
- lib/active_any/relation/where_clause.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #evaluate(adapter, record = nil) ⇒ Object
-
#initialize(key, value) ⇒ Condition
constructor
A new instance of Condition.
- #to_h ⇒ Object
Constructor Details
#initialize(key, value) ⇒ Condition
Returns a new instance of Condition.
9 10 11 12 13 14 15 16 17 |
# File 'lib/active_any/relation/where_clause.rb', line 9 def initialize(key, value) @key = key @value = value register_handler(BasicObject, :base_handler) register_handler(Regexp, :regexp_handler) register_handler(Range, :range_handler) register_handler(Array, :array_handler) end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/active_any/relation/where_clause.rb', line 7 def key @key end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/active_any/relation/where_clause.rb', line 7 def value @value end |
Instance Method Details
#evaluate(adapter, record = nil) ⇒ Object
19 20 21 |
# File 'lib/active_any/relation/where_clause.rb', line 19 def evaluate(adapter, record = nil) adapter.public_send(handle_for(value), record, key, value) end |
#to_h ⇒ Object
23 24 25 |
# File 'lib/active_any/relation/where_clause.rb', line 23 def to_h { key => value } end |