Skip to content

Instantly share code, notes, and snippets.

@inre
Created July 12, 2012 06:51
Show Gist options
  • Save inre/3096345 to your computer and use it in GitHub Desktop.
Save inre/3096345 to your computer and use it in GitHub Desktop.
Nice define method
class Object
def def(method, &b)
self.class.send(:define_method, method, &b)
end
end
# define method
object = Class.new
object.def :foo do |arg|
puts arg
end
# call method
object.foo("Hello world");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment