Module: MerchantSidekick::Sellable::ClassMethods

Defined in:
lib/merchant_sidekick/sellable.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_sellable(options = {}) ⇒ Object

Declares a model as sellable.

E.g.

class Product < ActiveRecord::Base
  acts_as_sellable :cents => :price_in_cents, :currency => false
end

@product.orders.


19
20
21
22
23
24
25
# File 'lib/merchant_sidekick/sellable.rb', line 19

def acts_as_sellable(options = {})
  include MerchantSidekick::Sellable::InstanceMethods
  extend MerchantSidekick::Sellable::SingletonMethods
  money :price, options
  has_many :line_items, :as => :sellable, :class_name => "MerchantSidekick::LineItem"
  has_many :orders, :through => :line_items, :class_name => "MerchantSidekick::Order"
end