def context(&block)
      # Include the context
      context = @context
      machine.owner_class.class_eval { include context }
      
      # Evaluate the method definitions and track which ones were added
      old_methods = context_methods
      context.class_eval(&block)
      new_methods = context_methods.to_a.select {|(name, method)| old_methods[name] != method}
      
      # Alias new methods so that the only execute when the object is in this state
      new_methods.each do |(method_name, method)|
        context_name = context_name_for(method_name)
        context.class_eval <<-end_eval, __FILE__, __LINE__ + 1
          alias_method :"#{context_name}", :#{method_name}
          def #{method_name}(*args, &block)
            state = self.class.state_machine(#{machine.name.inspect}).states.fetch(#{name.inspect})
            options = {:method_missing => lambda {super(*args, &block)}, :method_name => #{method_name.inspect}}
            state.call(self, :"#{context_name}", *(args + [options]), &block)
          end
        end_eval
      end
      
      true
    end
def context(&block)
      # Include the context
      context = @context
      machine.owner_class.class_eval { include context }
      
      # Evaluate the method definitions and track which ones were added
      old_methods = context_methods
      context.class_eval(&block)
      new_methods = context_methods.to_a.select {|(name, method)| old_methods[name] != method}
      
      # Alias new methods so that the only execute when the object is in this state
      new_methods.each do |(method_name, method)|
        context_name = context_name_for(method_name)
        context.class_eval <<-end_eval, __FILE__, __LINE__ + 1
          alias_method :"#{context_name}", :#{method_name}
          def #{method_name}(*args, &block)
            state = self.class.state_machine(#{machine.name.inspect}).states.fetch(#{name.inspect})
            options = {:method_missing => lambda {super(*args, &block)}, :method_name => #{method_name.inspect}}
            state.call(self, :"#{context_name}", *(args + [options]), &block)
          end
        end_eval
      end
      
      true
    end
Defines a context for the state which will be enabled on instances of
 the owner class when the machine is in this state.

 This can be called multiple times.  Each time a new context is created,
 a new module will be included in the owner class.