Skip to content

Instantly share code, notes, and snippets.

@santosh79
Created November 17, 2009 05:29
Show Gist options
  • Save santosh79/236671 to your computer and use it in GitHub Desktop.
Save santosh79/236671 to your computer and use it in GitHub Desktop.
automating includes with class_eval
module Hello
def say_hello
puts "hello"
end
end
[String, Array, Hash].each do |cls|
cls.class_eval { include Hello }
end
"cat".say_hello
[1,2].say_hello
{:1 => true, :2 => false}.say_hello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment