Skip to content

Instantly share code, notes, and snippets.

@tonini
Created February 4, 2010 14:24
Show Gist options
  • Save tonini/294668 to your computer and use it in GitHub Desktop.
Save tonini/294668 to your computer and use it in GitHub Desktop.
lambda {
hash = {}
Kernel.send :define_method, :say do |sentence, &block|
hash[sentence] = block
end
Kernel.send :define_method, :hello do |&block|
hash.each_pair do |sentence, say|
block.call sentence, say
end
end
}.call
say "hey dude!" do
12 > 2
end
hello do |sentence, say|
object = Object.new
puts "#{sentence}" if object.instance_eval &say # hey dude!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment