Skip to content

Instantly share code, notes, and snippets.

@headius
Created April 14, 2015 17:35
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 headius/d2e04a0580deffa415fc to your computer and use it in GitHub Desktop.
Save headius/d2e04a0580deffa415fc to your computer and use it in GitHub Desktop.
class Foo
def define(name, &block)
class << self; self; end.send(:define_method, name, block)
end
def define2(name, &block)
define(name, &block)
end
def test
define(:foo) { return 1 }
call_foo
puts :here
end
def call_foo
foo
end
end
Foo.new.test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment