I looked at all the posts above again, and realized that both, you li, 
and
Robert, have already presented the proper solution to your original
post. In fact you yourself, li, offered the solution at the end of your
first post above. Namely, contrary to the quote in 'The Ruby Programming
Language' book, the following code with 'define_method' works just fine:

  Kernel.send :define_method, :each_event do |events, &block|
    events.each_pair do |message, condition|
      block.call message, condition
    end
  end
  events = { one: 1, two: 2, three: 3 }
  each_event(events) { |m, c| puts "message:#{m}, condition:#{c}" }

-- 
Posted via http://www.ruby-forum.com/.