Class: Spree::OptionValue

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

Constant Summary collapse

TRANSLATABLE_FIELDS =
i[presentation].freeze

Class Method Summary collapse

Instance Method Summary collapse

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>)


65
66
67
68
69
70
71
72
# File 'app/models/spree/option_value.rb', line 65

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)


76
77
78
# File 'app/models/spree/option_value.rb', line 76

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