Module: Spree::MetafieldFilterable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Product
- Defined in:
- app/models/concerns/spree/metafield_filterable.rb
Overview
Resolves cf_* custom-field predicates (e.g. cf_custom_material_i_cont)
into scopes. Ransack has no such attributes, so callers split them out of a
filter hash with with_metafield_filters before handing the rest to
Ransack. Lives on the model rather than in a SearchProvider so every
consumer — the search providers, CSV export, any other Ransack entry
point — resolves the same vocabulary.
Constant Summary collapse
- NUMERIC_OPERATORS =
Arel comparison methods for numeric predicates.
{ 'eq' => :eq, 'gt' => :gt, 'gteq' => :gteq, 'lt' => :lt, 'lteq' => :lteq }.freeze
- LIKE_PATTERNS =
Wraps a value in the LIKE pattern its predicate implies.
{ 'cont' => ->(value) { "%#{value}%" }, 'i_cont' => ->(value) { "%#{value}%" }, 'start' => ->(value) { "#{value}%" }, 'end' => ->(value) { "%#{value}" } }.freeze