def define_action_hook
      action_hook = self.action_hook
      action = self.action
      private_action_hook = owner_class.private_method_defined?(action_hook)

      # Only define helper if it hasn't
      define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
          def #{action_hook}(*)
            self.class.state_machines.transitions(self, #{action.inspect}).perform { super }
          end
          
          private #{action_hook.inspect} if #{private_action_hook}
      end_eval
    end
def define_action_hook
      action_hook = self.action_hook
      action = self.action
      private_action_hook = owner_class.private_method_defined?(action_hook)

      # Only define helper if it hasn't
      define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
          def #{action_hook}(*)
            self.class.state_machines.transitions(self, #{action.inspect}).perform { super }
          end
          
          private #{action_hook.inspect} if #{private_action_hook}
      end_eval
    end
Hooks directly into actions by defining the same method in an included
 module.  As a result, when the action gets invoked, any state events
 defined for the object will get run.  Method visibility is preserved.