Skip to content

Instantly share code, notes, and snippets.

@wilson
Created October 16, 2009 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilson/211910 to your computer and use it in GitHub Desktop.
Save wilson/211910 to your computer and use it in GitHub Desktop.
obj = "something"
method_name = "foo"
obj.instance_eval <<-CODE
def #{method_name}
"blah"
end
CODE
# ... or..
class << obj
define_method(method_name) do
"blah"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment