Created
February 28, 2012 05:58
-
-
Save lsimoneau/1929985 to your computer and use it in GitHub Desktop.
DataMapper / State_Machine save hook issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dm-core' | |
require 'state_machine' | |
class Vehicle | |
include DataMapper::Resource | |
state_machine :initial => :parked do | |
event :ignite do | |
transition :parked => :idling | |
end | |
end | |
after :save do | |
ignite | |
end | |
end | |
DataMapper.setup(:default, :adapter => :in_memory) | |
v = Vehicle.new | |
v.save | |
p "State after saving is #{v.state}" | |
v.save | |
p "State after saving again is #{v.state}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment