class SaveTheMonth::ChargeDsl

Attributes

expected_balance[RW]

Public Instance Methods

evaluate_recipe(expected_balance, &recipe) click to toggle source
# File lib/charge_dsl.rb, line 5
def evaluate_recipe(expected_balance, &recipe)
  self.expected_balance = expected_balance
  instance_eval(&recipe)
end
method_missing(meth, *args, &blk) click to toggle source
# File lib/charge_dsl.rb, line 10
def method_missing(meth, *args, &blk)      
  charge_name = meth
  
  if block_given?
    expected_balance.add_charge(charge_name, &blk)
  else
    amount, options = args[0], args[1]
    amount_date = Date.parse(options[:at])
    expected_balance.add_timed_charge(charge_name, amount, amount_date)
  end
end