Class: IncomeTax::Models::Delegate

Inherits:
Generic
  • Object
show all
Defined in:
lib/income_tax/models/delegate.rb

Instance Attribute Summary

Attributes inherited from Generic

#gross_income, #net_income, #options, #rate, #taxes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generic

#based_on?, #cast_value, #cast_values, currency, #initialize, #inspect, lazy, #location_name, method_added, name, names, new, other_names, register, register_on, #set_default_options, #validate, wants_options

Constructor Details

This class inherits a constructor from IncomeTax::Models::Generic

Class Method Details

.delegate_to(base = nil) ⇒ Object



8
9
10
11
# File 'lib/income_tax/models/delegate.rb', line 8

def self.delegate_to(base = nil)
  @delegate_to   = base if base
  @delegate_to ||= superclass.delegate_to
end

Instance Method Details

#calculateObject



22
23
24
25
26
27
# File 'lib/income_tax/models/delegate.rb', line 22

def calculate
  @rate         = @delegate.rate
  @taxes        = @delegate.taxes
  @net_income   = @delegate.net_income
  @gross_income = @delegate.gross_income
end

#delegate_toObject



18
19
20
# File 'lib/income_tax/models/delegate.rb', line 18

def delegate_to
  self.class.delegate_to
end

#setup(options) ⇒ Object



13
14
15
16
# File 'lib/income_tax/models/delegate.rb', line 13

def setup(options)
  @delegate = delegate_to.new(**options)
  super
end