Class: MetaWhere::Condition

Inherits:
Object
  • Object
show all
Includes:
ConditionOperators, Utility
Defined in:
lib/meta_where/condition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConditionOperators

#&, #-, #-@, #|

Constructor Details

#initialize(column, value, method) ⇒ Condition

Returns a new instance of Condition.



11
12
13
14
15
# File 'lib/meta_where/condition.rb', line 11

def initialize(column, value, method)
  @column = column
  @value = value
  @method = (MetaWhere::METHOD_ALIASES[method.to_s] || method).to_s
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



9
10
11
# File 'lib/meta_where/condition.rb', line 9

def column
  @column
end

#methodObject (readonly)

Returns the value of attribute method.



9
10
11
# File 'lib/meta_where/condition.rb', line 9

def method
  @method
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/meta_where/condition.rb', line 9

def value
  @value
end

Instance Method Details

#==(other_condition) ⇒ Object Also known as: eql?



17
18
19
20
21
22
# File 'lib/meta_where/condition.rb', line 17

def ==(other_condition)
  other_condition.is_a?(Condition) &&
  other_condition.column == column &&
  other_condition.value == value    &&
  other_condition.method == method
end

#to_symObject

Play “nicely” with expand_hash_conditions_for_aggregates



27
28
29
# File 'lib/meta_where/condition.rb', line 27

def to_sym
  self
end