Sha256: 39e590ac2ac21969b9683f45b99b65f8910bd09af6a538720257b39b261f1197

Contents?: true

Size: 757 Bytes

Versions: 30

Compression:

Stored size: 757 Bytes

Contents

module ProductGroupSearch
  module CustomFieldStrategy
    def join(proxy)
      proxy.join(target_table).on(join_condition)
    end

    def join_condition
      target_table[:product_id].eq(Product.arel_table[:id])
    end

    def target_table
      unless @_target
        @_target =CustomFieldAnswer.arel_table.alias("answers#{index}")
      end
      @_target
    end

    def custom_field
      @_custom_field ||= CustomField.find(self.name)
    end

    def query_column
      field_type = custom_field.field_type
      if field_type == 'text'
        :value
      else
        "#{field_type}_value".to_sym
      end
    end

    def field_type
      custom_field.field_type
    end

    def localized_name
      custom_field.name
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
nimbleshop_core-0.0.23 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.21 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.20 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.19 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.17 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.16 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.15 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.14 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.14.rc2 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.14.rc1 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.13 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.12 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.11 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.10 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.9 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.8 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.7 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.5 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.4.beta1 lib/nimbleshop/product_group_search/custom_field_strategy.rb
nimbleshop_core-0.0.4 lib/nimbleshop/product_group_search/custom_field_strategy.rb