def define_event_helpers
      # Gets the events that are allowed to fire on the current object
      define_helper(:instance, attribute(:events)) do |machine, object, *args|
        machine.events.valid_for(object, *args).map { |event| event.name }
      end

      # Gets the next possible transitions that can be run on the current
      # object
      define_helper(:instance, attribute(:transitions)) do |machine, object, *args|
        machine.events.transitions_for(object, *args)
      end

      # Fire an arbitrary event for this machine
      define_helper(:instance, "fire_#{attribute(:event)}") do |machine, object, event, *args|
        machine.events.fetch(event).fire(object, *args)
      end

      # Add helpers for tracking the event / transition to invoke when the
      # action is called
      if action
        event_attribute = attribute(:event)
        define_helper(:instance, event_attribute) do |machine, object|
          # Interpret non-blank events as present
          event = machine.read(object, :event, true)
          event && !(event.respond_to?(:empty?) && event.empty?) ? event.to_sym : nil
        end

        # A roundabout way of writing the attribute is used here so that
        # integrations can hook into this modification
        define_helper(:instance, "#{event_attribute}=") do |machine, object, value|
          machine.write(object, :event, value, true)
        end

        event_transition_attribute = attribute(:event_transition)
        define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
            protected; attr_accessor #{event_transition_attribute.inspect}
        end_eval
      end
    end
def define_event_helpers
      # Gets the events that are allowed to fire on the current object
      define_helper(:instance, attribute(:events)) do |machine, object, *args|
        machine.events.valid_for(object, *args).map { |event| event.name }
      end

      # Gets the next possible transitions that can be run on the current
      # object
      define_helper(:instance, attribute(:transitions)) do |machine, object, *args|
        machine.events.transitions_for(object, *args)
      end

      # Fire an arbitrary event for this machine
      define_helper(:instance, "fire_#{attribute(:event)}") do |machine, object, event, *args|
        machine.events.fetch(event).fire(object, *args)
      end

      # Add helpers for tracking the event / transition to invoke when the
      # action is called
      if action
        event_attribute = attribute(:event)
        define_helper(:instance, event_attribute) do |machine, object|
          # Interpret non-blank events as present
          event = machine.read(object, :event, true)
          event && !(event.respond_to?(:empty?) && event.empty?) ? event.to_sym : nil
        end

        # A roundabout way of writing the attribute is used here so that
        # integrations can hook into this modification
        define_helper(:instance, "#{event_attribute}=") do |machine, object, value|
          machine.write(object, :event, value, true)
        end

        event_transition_attribute = attribute(:event_transition)
        define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
            protected; attr_accessor #{event_transition_attribute.inspect}
        end_eval
      end
    end
Adds helper methods for getting information about this state machine's
 events