Class: Spree::Variants::OptionTypesFinder
- Inherits:
-
Object
- Object
- Spree::Variants::OptionTypesFinder
- Defined in:
- app/finders/spree/variants/option_types_finder.rb
Constant Summary collapse
- COLOR_TYPE =
'color'.freeze
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(variant_ids:) ⇒ OptionTypesFinder
constructor
A new instance of OptionTypesFinder.
Constructor Details
#initialize(variant_ids:) ⇒ OptionTypesFinder
Returns a new instance of OptionTypesFinder.
6 7 8 |
# File 'app/finders/spree/variants/option_types_finder.rb', line 6 def initialize(variant_ids:) @variant_ids = variant_ids end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 |
# File 'app/finders/spree/variants/option_types_finder.rb', line 10 def execute Spree::OptionType.includes(option_values: :variants).where(spree_variants: { id: variant_ids }). reorder('spree_option_types.position ASC, spree_option_values.position ASC'). partition { |option_type| option_type.name.downcase == COLOR_TYPE }.flatten end |