Skip to content

Instantly share code, notes, and snippets.

@scaint
Created July 26, 2015 20:44
Show Gist options
  • Save scaint/dd3a868629401ba62c80 to your computer and use it in GitHub Desktop.
Save scaint/dd3a868629401ba62c80 to your computer and use it in GitHub Desktop.
public.class_eval { def say_hello; 'Hello!'; end }
:ruby.say_hello # => "Hello!"
public.class.class_eval { public :define_method } # First we need to change visibility of define_method() :)
public.define_method(:say_hello) { 'Hello' }
nil.say_hello # => 'Hello!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment