2015-05-15 06:50:29 -04:00
|
|
|
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
|
2015-06-26 03:46:58 -04:00
|
|
|
|
|
|
|
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
|