Permalink
Browse files

Minor doc tweaks

  • Loading branch information...
1 parent 39609dd commit 8ea3d849bb41a6d2376fa067e1b555debfc19906 @obrie obrie committed Aug 10, 2009
@@ -142,7 +142,7 @@ def known_states
# requirements configured for this callback.
#
# If a terminator has been configured and it matches the result from the
- # evaluated method, then the callback chain should be halted
+ # evaluated method, then the callback chain should be halted.
def call(object, context = {}, *args)
if @guard.matches?(object, context)
@methods.each do |method|
@@ -65,8 +65,8 @@ def initialize_copy(orig) #:nodoc:
# state to be +idling+ if it's current state is +parked+ or +first_gear+
# if it's current state is +idling+.
#
- # To help defining these implicit transitions, a set of helpers are available
- # for defining slightly more complex matching:
+ # To help define these implicit transitions, a set of helpers are available
+ # for slightly more complex matching:
# * <tt>all</tt> - Matches every state in the machine
# * <tt>all - [:parked, :idling, ...]</tt> - Matches every state except those specified
# * <tt>any</tt> - An alias for +all+ (matches every state in the machine)
@@ -34,6 +34,14 @@ def valid_for(object)
# Gets the list of transitions that can be run on the given object.
#
+ # Valid requirement options:
+ # * <tt>:from</tt> - One or more states being transitioned from. If none
+ # are specified, then this will be the object's current state.
+ # * <tt>:to</tt> - One or more states being transitioned to. If none are
+ # specified, then this will match any to state.
+ # * <tt>:on</tt> - One or more events that fire the transition. If none
+ # are specified, then this will match any event.
+ #
# == Examples
#
# class Vehicle
@@ -50,22 +58,25 @@ def valid_for(object)
#
# events = Vehicle.state_machine.events
#
- # vehicle = Vehicle.new # => #<Vehicle:0xb7c464b0 @state="parked">
- # events.transitions_for(vehicle) # => [#<StateMachine::Transition attribute=:state event=:ignite from="parked" from_name=:parked to="idling" to_name=:idling>]
+ # vehicle = Vehicle.new # => #<Vehicle:0xb7c464b0 @state="parked">
+ # events.transitions_for(vehicle) # => [#<StateMachine::Transition attribute=:state event=:ignite from="parked" from_name=:parked to="idling" to_name=:idling>]
#
# vehicle.state = 'idling'
- # events.transitions_for(vehicle) # => [#<StateMachine::Transition attribute=:state event=:park from="idling" from_name=:idling to="parked" to_name=:parked>]
+ # events.transitions_for(vehicle) # => [#<StateMachine::Transition attribute=:state event=:park from="idling" from_name=:idling to="parked" to_name=:parked>]
+ #
+ # # Search for explicit transitions regardless of the current state
+ # events.transitions_for(vehicle, :from => :parked) # => [#<StateMachine::Transition attribute=:state event=:ignite from="parked" from_name=:parked to="idling" to_name=:idling>]
def transitions_for(object, requirements = {})
map {|event| event.transition_for(object, requirements)}.compact
end
# Gets the transition that should be performed for the event stored in the
# given object's event attribute. This also takes an additional parameter
- # for automatically invalidating the object if the event or transition
- # are invalid. By default, this is turned off.
+ # for automatically invalidating the object if the event or transition are
+ # invalid. By default, this is turned off.
#
- # *Note* that if a transition has already been generated for the event,
- # then that transition will be used.
+ # *Note* that if a transition has already been generated for the event, then
+ # that transition will be used.
#
# == Examples
#
@@ -47,7 +47,7 @@ def fire_events(object, *events)
end
# Runs one or more event attributes in parallel during the invocation of
- # an action on the given object. After transition callbacks can be
+ # an action on the given object. after_transition callbacks can be
# optionally disabled if the events are being only partially fired (for
# example, when validating records in ORM integrations).
#

0 comments on commit 8ea3d84

Please sign in to comment.