Class: Spree::Amazon::Variant

Inherits:
Product show all
Defined in:
app/models/spree/amazon/variant.rb

Instance Attribute Summary collapse

Attributes inherited from Product

#binds, #created_at, #description, #id, #images, #name, #price, #props, #props_str, #sale_props, #taxon_id, #taxon_name, #taxons, #updated_at, #url, #variant_attributes, #variant_options, #variants

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Product

#available?, class_name, find, #has_stock?, #has_variants?, #master, multi_find, name, #possible_promotions, prepare_id, root_page, #save_to_spree, save_to_spree_or_find, search, #to_param

Methods inherited from Base

#attributes=, #initialize, #to_param

Constructor Details

This class inherits a constructor from Spree::Amazon::Base

Instance Attribute Details

#productObject

Returns the value of attribute product



4
5
6
# File 'app/models/spree/amazon/variant.rb', line 4

def product
  @product
end

Class Method Details

.build_variants_collection(product, variants = []) ⇒ Object



26
27
28
# File 'app/models/spree/amazon/variant.rb', line 26

def build_variants_collection(product, variants=[])
  Spree::Amazon::VariantCollection.new( (variants).map{ |x| new(x.merge(:product => product)) } )
end

Instance Method Details

#in_stockObject



12
13
14
# File 'app/models/spree/amazon/variant.rb', line 12

def in_stock
  1
end

#option_valuesObject



15
16
17
# File 'app/models/spree/amazon/variant.rb', line 15

def option_values
  @variant_options || []
end

#options_textObject

attr_accessor :variant_attributes



7
8
9
10
11
# File 'app/models/spree/amazon/variant.rb', line 7

def options_text
  (@variant_options || []).map{ |x|
    "#{x[:name]}: #{x[:value]}"
  }.to_sentence({:words_connector => ", ", :two_words_connector => ", "})
end