Class: ProductGroupSearch::BaseField

Inherits:
Object
  • Object
show all
Defined in:
lib/nimbleshop/product_group_search/base_field.rb

Direct Known Subclasses

NumberField, TextField

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(condition) ⇒ BaseField

Returns a new instance of BaseField.



6
7
8
# File 'lib/nimbleshop/product_group_search/base_field.rb', line 6

def initialize(condition)
  self.condition = condition
end

Instance Attribute Details

#conditionObject

Returns the value of attribute condition.



3
4
5
# File 'lib/nimbleshop/product_group_search/base_field.rb', line 3

def condition
  @condition
end

Instance Method Details

#valid_operator?(operator) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/nimbleshop/product_group_search/base_field.rb', line 10

def valid_operator?(operator)
  valid_operators.include?(operator.to_s)
end

#where(proxy = nil) ⇒ Object



14
15
16
17
# File 'lib/nimbleshop/product_group_search/base_field.rb', line 14

def where(proxy = nil)
  clause = send(condition.operator, coerced_value)
  proxy ? proxy.and(clause) : clause
end