Sha256: 8c0007e6803de8539d1ad6cca74be27864945b68c39afc4472a65b8989aa04c0

Contents?: true

Size: 734 Bytes

Versions: 52

Compression:

Stored size: 734 Bytes

Contents

class Piggybak::Variant < ActiveRecord::Base
  belongs_to :item, :polymorphic => true, :inverse_of => :piggybak_variant
  attr_accessible :sku, :description, :price, :quantity, :active, :unlimited_inventory, :item_id, :item_type 
  attr_accessible :item # to allow direct assignment from code or console

  validates_presence_of :sku
  validates_uniqueness_of :sku
  validates_presence_of :description
  validates_presence_of :price
  validates_presence_of :item_type
  validates_numericality_of :quantity, :only_integer => true, :greater_than_or_equal_to => 0
    
  def admin_label
    "Variant: #{self.description}"
  end

  def update_inventory(purchased)
    self.update_attribute(:quantity, self.quantity + purchased)
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
piggybak-0.5.5 app/models/piggybak/variant.rb
piggybak-0.5.4 app/models/piggybak/variant.rb
piggybak-0.5.3 app/models/piggybak/variant.rb
piggybak-0.5.2 app/models/piggybak/variant.rb
piggybak-0.5.1 app/models/piggybak/variant.rb
piggybak-0.5.0 app/models/piggybak/variant.rb
piggybak-0.4.39 app/models/piggybak/variant.rb
piggybak-0.4.38 app/models/piggybak/variant.rb
piggybak-0.4.37 app/models/piggybak/variant.rb
piggybak-0.4.36 app/models/piggybak/variant.rb
piggybak-0.4.35 app/models/piggybak/variant.rb
piggybak-0.4.34 app/models/piggybak/variant.rb
piggybak-0.4.33 app/models/piggybak/variant.rb
piggybak-0.4.32 app/models/piggybak/variant.rb
piggybak-0.4.31 app/models/piggybak/variant.rb
piggybak-0.4.30 app/models/piggybak/variant.rb
piggybak-0.4.29 app/models/piggybak/variant.rb
piggybak-0.4.28 app/models/piggybak/variant.rb
piggybak-0.4.27 app/models/piggybak/variant.rb
piggybak-0.4.26 app/models/piggybak/variant.rb