Module: ProductGroupSearch::CustomFieldStrategy
- Defined in:
- lib/nimbleshop/product_group_search/custom_field_strategy.rb
Instance Method Summary collapse
- #custom_field ⇒ Object
- #field_type ⇒ Object
- #join(proxy) ⇒ Object
- #join_condition ⇒ Object
- #localized_name ⇒ Object
- #query_column ⇒ Object
- #target_table ⇒ Object
Instance Method Details
#custom_field ⇒ Object
18 19 20 |
# File 'lib/nimbleshop/product_group_search/custom_field_strategy.rb', line 18 def custom_field @_custom_field ||= CustomField.find(self.name) end |
#field_type ⇒ Object
31 32 33 |
# File 'lib/nimbleshop/product_group_search/custom_field_strategy.rb', line 31 def field_type custom_field.field_type end |
#join(proxy) ⇒ Object
3 4 5 |
# File 'lib/nimbleshop/product_group_search/custom_field_strategy.rb', line 3 def join(proxy) proxy.join(target_table).on(join_condition) end |
#join_condition ⇒ Object
7 8 9 |
# File 'lib/nimbleshop/product_group_search/custom_field_strategy.rb', line 7 def join_condition target_table[:product_id].eq(Product.arel_table[:id]) end |
#localized_name ⇒ Object
35 36 37 |
# File 'lib/nimbleshop/product_group_search/custom_field_strategy.rb', line 35 def localized_name custom_field.name end |
#query_column ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/nimbleshop/product_group_search/custom_field_strategy.rb', line 22 def query_column field_type = custom_field.field_type if field_type == 'text' :value else "#{field_type}_value".to_sym end end |
#target_table ⇒ Object
11 12 13 14 15 16 |
# File 'lib/nimbleshop/product_group_search/custom_field_strategy.rb', line 11 def target_table unless @_target @_target =CustomFieldAnswer.arel_table.alias("answers#{index}") end @_target end |