Class: Spree::Variants::OptionTypesPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/spree/variants/option_types_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(option_types, variants, product) ⇒ OptionTypesPresenter

Returns a new instance of OptionTypesPresenter.



4
5
6
7
8
# File 'app/presenters/spree/variants/option_types_presenter.rb', line 4

def initialize(option_types, variants, product)
  @option_types = option_types
  @variant_ids = variants.map(&:id)
  @product = product
end

Instance Method Details

#default_variantObject



10
11
12
# File 'app/presenters/spree/variants/option_types_presenter.rb', line 10

def default_variant
  default_variant_data[:variant]
end

#optionsObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/presenters/spree/variants/option_types_presenter.rb', line 14

def options
  option_types.map do |option_type|
    {
      id: option_type.id,
      name: option_type.name,
      presentation: option_type.presentation,
      position: option_type.position,
      option_values: option_values_options(option_type.option_values)
    }
  end
end