Module: GetsTrollied::ClassMethods

Defined in:
lib/gets_trollied.rb

Instance Method Summary collapse

Instance Method Details

#set_up_to_get_trollied(*args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gets_trollied.rb', line 10

def set_up_to_get_trollied(*args)
  options = args.last.is_a?(Hash) ? args.pop : Hash.new

  # don't allow multiple calls
  return if self.included_modules.include?(GetsTrollied::InstanceMethods)

  send :include, GetsTrollied::InstanceMethods

  send :has_many, :line_items, :as => :purchasable_item, :dependent => :destroy

  cattr_accessor :described_as_when_purchasing
  self.described_as_when_purchasing = options[:described_as] || :name

  cattr_accessor :as_foreign_key_sym
  self.as_foreign_key_sym = self.name.foreign_key.to_sym

end