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 Helpers::AssociationHelper

#belongs_to, #has_many

Methods included from Helpers::ValidationHelper

#errors, #valid?

Methods included from Helpers::SerializationHelper

#_serialize, #as_json, #root, #serializable_hash, #serialize_attribute

Methods included from Helpers::InspectionHelper

#inspect

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)


79
80
81
82
83
84
85
86
# File 'lib/gecko/record/variant.rb', line 79

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