Module: Bean::Machine::InstanceMethods

Defined in:
lib/bean/machine.rb

Instance Method Summary collapse

Instance Method Details

#beanObject



11
12
13
# File 'lib/bean/machine.rb', line 11

def bean
  transfers.stateful.first
end

#transfer(*args, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bean/machine.rb', line 15

def transfer(*args,&block)
  options = args.last.is_a?(Hash) ? args.pop : {}
  amount = args.shift.to_money
  
  options.reverse_merge!({
    :amount => amount
  })
  
  xfer = self.transfers.build(options)
  xfer.instance_eval(&block)
  xfer.save
  xfer
end