Class: Billing::Modifier

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
BillItem
Defined in:
app/models/billing/modifier.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.wild_args(*args) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/models/billing/modifier.rb', line 25

def wild_args(*args)
  case when args.blank? || args.first.kind_of?(Hash) then
    {}.merge(*args)
  when args.first.kind_of?(String) then
    d = args.shift
    if d.index('%')
      #TODO parse
    end
  else
    h = { fixed_value: args.shift.to_money }
    args.any? ? h.merge(*args) : h
  end
end

Instance Method Details

#humanObject



14
15
16
# File 'app/models/billing/modifier.rb', line 14

def human
  percent_ratio.nil? ? fixed_value : "#{(percent_ratio * 100).to_i}%" 
end