Gavin Kistner schrieb:
> ...
> Unfortunately, I can't figure out how to get an instance of a class  to 
> invoke a block stored in its parent class, using the scope of the  
> instance for the block. In JS this would be easy, but I don't yet  grok 
> how to have Ruby run a set of code on any arbitrary scope (while  
> passing parameters to that code).

Hi Gavin,

executing a code block in the context of an object is normally done via 
instance_eval, but I, too, couldn't find a way to pass parameters to the 
block.

One workaround is to create methods for the states. If you change the 
following methods of FiniteStateMachine, it should work:

   class FiniteStateMachine

     ...

     def self.add_state( start_state, &block )
       name = "__state_#{start_state}"
       states[ start_state ] = name
       define_method( name, &block )
     end

     ...

     def transition( trigger )
       @state = send( self.class.states[ @state ], trigger )
     end

   end

Regards,
Pit