Module: Mongoid::Monetize::ClassMethods

Defined in:
lib/money/mongoid/monetize.rb

Instance Method Summary collapse

Instance Method Details

#monetize_many(name, options = {:as => :priced}) ⇒ Object

alias_method :monetize, :monetize_one



20
21
22
23
24
25
26
# File 'lib/money/mongoid/monetize.rb', line 20

def monetize_many name, options = {:as => :priced}
	as_poly = options.delete(:as) || default_polymorphic_money
	unless as_poly
		raise ArgumentError, "You must set an :as option indicating the polymorphic Monetizable model. See money-rails gem."
	end					
	self.embeds_many name, options.merge(:as => as_poly)
end

#monetize_one(name, options = {:as => :priced}) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/money/mongoid/monetize.rb', line 9

def monetize_one name, options = {:as => :priced}
	as_poly = options.delete(:as) || default_polymorphic_money
	
	unless as_poly
		raise ArgumentError, "You must set an :as option indicating the polymorphic Monetizable model - was: #{options}. See money-rails gem."
	end

	self.embeds_one name.to_sym, options.merge(:as => as_poly)
end