1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00
aasm/spec/models/initial_state_proc.rb
Thorsten Böttger 206b1991bc more tests
2015-06-26 19:46:58 +12:00

31 lines
704 B
Ruby

class InitialStateProc
RICH = 1_000_000
attr_accessor :balance
include AASM
aasm do
state :retired
state :selling_bad_mortgages
initial_state Proc.new { |banker| banker.rich? ? :retired : :selling_bad_mortgages }
end
def initialize(balance = 0); self.balance = balance; end
def rich?; self.balance >= RICH; end
end
class InitialStateProcMultiple
RICH = 1_000_000
attr_accessor :balance
include AASM
aasm(:left) do
state :retired
state :selling_bad_mortgages
initial_state Proc.new { |banker| banker.rich? ? :retired : :selling_bad_mortgages }
end
def initialize(balance = 0); self.balance = balance; end
def rich?; self.balance >= RICH; end
end