Module: MerchantSidekick::Buyer::ClassMethods
- Defined in:
- lib/merchant_sidekick/buyer.rb
Instance Method Summary collapse
-
#acts_as_buyer ⇒ Object
Defines helper methods for a person buying items.
Instance Method Details
#acts_as_buyer ⇒ Object
Defines helper methods for a person buying items.
E.g.
class Client < ActiveRecord::Base
acts_as_buyer
...
end
# Simple purchase
# => @client.purchase @products
# Purchase referencing a seller
# => @client.purchase @products, :from => @merchant
# Same as above
# => @client.purchase_from @merchant, @products
28 29 30 31 32 33 34 |
# File 'lib/merchant_sidekick/buyer.rb', line 28 def acts_as_buyer include MerchantSidekick::Buyer::InstanceMethods has_many :orders, :as => :buyer, :dependent => :destroy, :class_name => "::MerchantSidekick::Order" has_many :invoices, :as => :buyer, :dependent => :destroy, :class_name => "::MerchantSidekick::Invoice" has_many :purchase_orders, :as => :buyer, :class_name => "::MerchantSidekick::PurchaseOrder" has_many :purchase_invoices, :as => :buyer, :class_name => "::MerchantSidekick::PurchaseInvoice" end |