Class: MetaWhere::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_where/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column, method) ⇒ Column

Returns a new instance of Column.



5
6
7
8
# File 'lib/meta_where/column.rb', line 5

def initialize(column, method)
  @column = column
  @method = method
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



3
4
5
# File 'lib/meta_where/column.rb', line 3

def column
  @column
end

#methodObject (readonly)

Returns the value of attribute method.



3
4
5
# File 'lib/meta_where/column.rb', line 3

def method
  @method
end

Instance Method Details

#%(value) ⇒ Object



10
11
12
# File 'lib/meta_where/column.rb', line 10

def %(value)
  MetaWhere::Condition.new(column, value, method)
end

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



14
15
16
17
18
# File 'lib/meta_where/column.rb', line 14

def ==(other_column)
  other_column.is_a?(Column)    &&
  other_column.column == column &&
  other_column.method == method
end

#hashObject



22
23
24
# File 'lib/meta_where/column.rb', line 22

def hash
  [column, method].hash
end

#to_symObject

Play nicely with expand_hash_conditions_for_aggregates



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

def to_sym
  "#{column}.#{method}".to_sym
end