README.rdoc in state_machine-0.7.0 vs README.rdoc in state_machine-0.7.1
- old
+ new
@@ -161,10 +161,14 @@
def fix
# get the vehicle fixed by a mechanic
end
end
+*Note* the comment made on the +initialize+ method in the class. In order for
+state machine attributes to be properly initialized, <tt>super()</tt> must be called.
+See StateMachine::MacroMethods for more information about this.
+
Using the above class as an example, you can interact with the state machine
like so:
vehicle = Vehicle.new # => #<Vehicle:0xb7cf4eac @state="parked", @seatbelt_on=false>
vehicle.state # => "parked"
@@ -215,14 +219,10 @@
vehicle.state_name # => :first_gear
vehicle.alarm_state_name # => :active
vehicle.fire_events!(:ignite, :enable_alarm) # => StateMachine::InvalidTransition: Cannot run events in parallel: ignite, enable_alarm
-*Note* the comment made on the +initialize+ method in the class. In order for
-state machine attributes to be properly initialized, <tt>super()</tt> must be called.
-See StateMachine::MacroMethods for more information about this.
-
== Integrations
In addition to being able to define state machines on all Ruby classes, a set of
out-of-the-box integrations are available for some of the more popular Ruby
libraries. These integrations add library-specific behavior, allowing for state
@@ -265,11 +265,11 @@
# Callback for :ignite event *before* the transition is performed
def before_ignite(vehicle, transition)
# log message
end
- # Generic transition callback *before* the transition is performed
+ # Generic transition callback *after* the transition is performed
def after_transition(vehicle, transition)
Audit.log(vehicle, transition)
end
end
@@ -316,10 +316,10 @@
# Callback for :ignite event *before* the transition is performed
before_transition :on => :ignite do |transition|
# log message (self is the record)
end
- # Generic transition callback *before* the transition is performed
+ # Generic transition callback *after* the transition is performed
after_transition do |transition|
Audit.log(self, transition) # self is the record
end
end