lib/state_machine/machine.rb in state_machine-0.9.3 vs lib/state_machine/machine.rb in state_machine-0.9.4

- old
+ new

@@ -481,11 +481,11 @@ extend class_helper_module include instance_helper_module end # Add class-/instance-level methods to the owner class for state initialization - unless owner_class.included_modules.include?(StateMachine::InstanceMethods) + unless owner_class < StateMachine::InstanceMethods owner_class.class_eval do extend StateMachine::ClassMethods include StateMachine::InstanceMethods end @@ -926,15 +926,19 @@ # validations, use event attributes (e.g. state_event) as described in the # "Events" documentation of each ORM integration. # * <tt>park_transition</tt> - Gets the next transition that would be # performed if the "park" event were to be fired now on the object or nil # if no transitions can be performed. - # * <tt>park(run_action = true)</tt> - Fires the "park" event, transitioning - # from the current state to the next valid state. - # * <tt>park!(run_action = true)</tt> - Fires the "park" event, transitioning - # from the current state to the next valid state. If the transition fails, - # then a StateMachine::InvalidTransition error will be raised. + # * <tt>park(..., run_action = true)</tt> - Fires the "park" event, + # transitioning from the current state to the next valid state. If the + # last argument is a boolean, it will control whether the machine's action + # gets run. + # * <tt>park!(..., run_action = true)</tt> - Fires the "park" event, + # transitioning from the current state to the next valid state. If the + # transition fails, then a StateMachine::InvalidTransition error will be + # raised. If the last argument is a boolean, it will control whether the + # machine's action gets run. # # With a namespace of "car", the above names map to the following methods: # * <tt>can_park_car?</tt> # * <tt>park_car_transition</tt> # * <tt>park_car</tt> @@ -992,17 +996,25 @@ # def take_deep_breath # sleep 3 # end # end # - # Note that +super+ is called instead of <tt>super(*args)</tt>. This - # allows the entire arguments list to be accessed by transition callbacks - # through StateMachine::Transition#args like so: + # Note that +super+ is called instead of <tt>super(*args)</tt>. This allows + # the entire arguments list to be accessed by transition callbacks through + # StateMachine::Transition#args like so: # # after_transition :on => :park do |vehicle, transition| # kind = *transition.args # ... # end + # + # *Remember* that if the last argument is a boolean, it will be used as the + # +run_action+ parameter to the event action. Using the +park+ action + # example from above, you can might call it like so: + # + # vehicle.park # => Uses default args and runs machine action + # vehicle.park(:parallel) # => Specifies the +kind+ argument and runs the machine action + # vehicle.park(:parallel, false) # => Specifies the +kind+ argument and *skips* the machine action # # == Example # # class Vehicle # state_machine do