Class: Dynomite::Item::Query::Relation::WhereField

Inherits:
Object
  • Object
show all
Defined in:
lib/dynomite/item/query/relation/where_field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_field, value, index) ⇒ WhereField

Returns a new instance of WhereField.



4
5
6
# File 'lib/dynomite/item/query/relation/where_field.rb', line 4

def initialize(full_field, value, index)
  @full_field, @value, @index = full_field.to_s, value, index
end

Instance Attribute Details

#full_fieldObject (readonly)

Returns the value of attribute full_field.



3
4
5
# File 'lib/dynomite/item/query/relation/where_field.rb', line 3

def full_field
  @full_field
end

#indexObject (readonly)

Returns the value of attribute index.



3
4
5
# File 'lib/dynomite/item/query/relation/where_field.rb', line 3

def index
  @index
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/dynomite/item/query/relation/where_field.rb', line 3

def value
  @value
end

Instance Method Details

#fieldObject



8
9
10
# File 'lib/dynomite/item/query/relation/where_field.rb', line 8

def field
  @full_field.split('.').first
end

#not?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/dynomite/item/query/relation/where_field.rb', line 18

def not?
  raw_operator.match(/^not_/) if raw_operator
end

#operatorObject



12
13
14
15
16
# File 'lib/dynomite/item/query/relation/where_field.rb', line 12

def operator
  if raw_operator
    not? ? raw_operator[4..-1] : raw_operator
  end
end

#raw_operatorObject



22
23
24
25
# File 'lib/dynomite/item/query/relation/where_field.rb', line 22

def raw_operator
  _, operator = @full_field.split('.')
  operator.downcase if operator
end

#referenceObject

Example: price_1, price_2



28
29
30
# File 'lib/dynomite/item/query/relation/where_field.rb', line 28

def reference
  "#{field}_#{@index}"
end