Module: DeathAndTaxes::Taxable::ClassMethods
- Defined in:
- lib/death_and_taxes/taxable.rb
Instance Method Summary collapse
-
#acts_as_taxable(*args) ⇒ Object
Makes this model taxable It will then be able to have taxations applied Example: class Invoicing < ActiveRecord::Base acts_as_taxable end.
- #calculate_rate(taxes) ⇒ Object
Instance Method Details
#acts_as_taxable(*args) ⇒ Object
Makes this model taxable It will then be able to have taxations applied Example:
class Invoicing < ActiveRecord::Base
acts_as_taxable
end
17 18 19 20 21 22 23 24 |
# File 'lib/death_and_taxes/taxable.rb', line 17 def acts_as_taxable(*args) class_eval do has_many :taxations, :as => :taxable, :class_name => 'DeathAndTaxes::Taxation' end include DeathAndTaxes::Taxable::InstanceMethods end |
#calculate_rate(taxes) ⇒ Object
26 27 28 |
# File 'lib/death_and_taxes/taxable.rb', line 26 def calculate_rate taxes taxes.reduce(1) { |rate, tax| rate + tax.apply(1) } end |