On implementing a state machine I'm stuck at...


h = Hash::new
h["func1"] = "Outer::Inner::dothis"
h["func2"] = "whatever"

def whatever(x)
 puts "whatever happens #{x}"
end

module Outer
  module Inner
    def dothis(c)
      puts "I did it #{c} times"
    end    
    module_function :dothis
  end
end

Outer::Inner::dothis(3)
__send__(h["func2"],9)
__send__(h["func1"],7)

=== cut here ===

$ ruby ztrick.rb 

I did it 3 times
whatever happens 9
ztrick.rb:21:in '__send__': undefined method 'Outer::Inner::dothis' for main:Object (NoMethodError)
        from ztest.rb:21



local calls look ok - how to do dynamic calls across module/class boundaries?
consider the hash mostly populated first and the functions are defined later
(or never at all)
I'm not even sure whether this is a syntax or missunderstanding issue :-/

any hints on how to do a fast state machine appreciated

thanks!
Martin