def run_callbacks(index = 0)
        if index == 0
          # Clears any traces of the event attribute to prevent it from being
          # evaluated multiple times if actions are nested
          each do |transition|
            transition.machine.write(object, :event, nil)
            transition.machine.write(object, :event_transition, nil)
          end
          
          # Rollback only if exceptions occur during before callbacks
          begin
            super
          rescue
            rollback unless @before_run
            @success = nil  # mimics ActiveRecord.save behavior on rollback
            raise
          end
          
          # Persists transitions on the object if partial transition was successful.
          # This allows us to reference them later to complete the transition with
          # after callbacks.          
          each {|transition| transition.machine.write(object, :event_transition, transition)} if skip_after && success?
        else
          super
        end
      end
def run_callbacks(index = 0)
        if index == 0
          # Clears any traces of the event attribute to prevent it from being
          # evaluated multiple times if actions are nested
          each do |transition|
            transition.machine.write(object, :event, nil)
            transition.machine.write(object, :event_transition, nil)
          end
          
          # Rollback only if exceptions occur during before callbacks
          begin
            super
          rescue
            rollback unless @before_run
            @success = nil  # mimics ActiveRecord.save behavior on rollback
            raise
          end
          
          # Persists transitions on the object if partial transition was successful.
          # This allows us to reference them later to complete the transition with
          # after callbacks.          
          each {|transition| transition.machine.write(object, :event_transition, transition)} if skip_after && success?
        else
          super
        end
      end
Hooks into running transition callbacks so that event / event transition
 attributes can be properly updated