Class: Spree::Variants::OptionsPresenter

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

Constant Summary collapse

WORDS_CONNECTOR =
', '.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variant) ⇒ OptionsPresenter

Returns a new instance of OptionsPresenter.



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

def initialize(variant)
  Spree::Deprecation.warn('Spree::Variants::OptionsPresenter is deprecated and will be removed in Spree 5.5. Please use Spree::Variant#options_text instead.')
  @variant = variant
end

Instance Attribute Details

#variantObject (readonly)

Returns the value of attribute variant.



6
7
8
# File 'app/presenters/spree/variants/options_presenter.rb', line 6

def variant
  @variant
end

Instance Method Details

#to_hashObject



23
24
25
26
27
28
29
# File 'app/presenters/spree/variants/options_presenter.rb', line 23

def to_hash
  options = option_values
  options = sort_options(options)
  options = present_options_as_hash(options)

  join_hash_options(options)
end

#to_sentenceObject



15
16
17
18
19
20
21
# File 'app/presenters/spree/variants/options_presenter.rb', line 15

def to_sentence
  options = option_values
  options = sort_options(options)
  options = present_options(options)

  join_options(options)
end