Class: ActiveAny::Relation::WhereClause::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/active_any/relation/where_clause.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/active_any/relation/where_clause.rb', line 7

def key
  @key
end

#valueObject (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_hObject



23
24
25
# File 'lib/active_any/relation/where_clause.rb', line 23

def to_h
  { key => value }
end