Class: Spree::OptionValue

Inherits:
Object
  • Object
show all
Includes:
Metadata, Metafields, ParameterizableName, PresentationTranslatable
Defined in:
app/models/spree/option_value.rb

Constant Summary collapse

TRANSLATABLE_FIELDS =
Spree::PresentationTranslatable::TRANSLATABLE_FIELDS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PresentationTranslatable

#label, #label=

Methods included from TranslatableResource

#get_field_with_locale, #translatable_store, #upsert_translations

Methods included from Metadata

#metadata, #metadata=, #public_metadata=

Class Method Details

.to_tom_select_jsonArray<Hash>

Using map here instead of pluck, as these values are translatable via Mobility gem

Returns:

  • (Array<Hash>)


71
72
73
74
75
76
77
78
# File 'app/models/spree/option_value.rb', line 71

def self.to_tom_select_json
  all.map do |ov|
    {
      id: ov.name,
      name: ov.presentation
    }
  end
end

Instance Method Details

#display_presentationString

Returns the presentation with the option type presentation, eg. "Color: Red"

Returns:

  • (String)


82
83
84
# File 'app/models/spree/option_value.rb', line 82

def display_presentation
  @display_presentation ||= "#{option_type.presentation}: #{presentation}"
end