Class: Gecko::Record::Variant

Inherits:
Base
  • Object
show all
Defined in:
lib/gecko/record/variant.rb

Defined Under Namespace

Classes: VariantLocation, VariantPrice

Instance Method Summary collapse

Methods inherited from Base

demodulized_name, #initialize, #persisted?, #save

Methods included from LiquidCompatibility

#to_liquid

Methods included from Helpers::ValidationHelper

#errors, #valid?

Methods included from Helpers::SerializationHelper

#_serialize, #as_json, #root, #serializable_hash, #serialize_attribute, #writeable?

Methods included from Helpers::InspectionHelper

#inspect

Methods included from Helpers::AssociationHelper

included

Constructor Details

This class inherits a constructor from Gecko::Record::Base

Instance Method Details

#display_nameString

Returns a display name for a variant

Examples:

variant.display_name #=> "ABC12-Alpha Rocket"

Returns:

  • (String)


88
89
90
91
92
93
94
95
# File 'lib/gecko/record/variant.rb', line 88

def display_name
  parts = if name.nil? || !name.include?(product_name)
            [sku, product_name, name]
          else
            [sku, name]
          end
  parts.select { |part| part&.length }.join(' - ')
end