Created
July 4, 2012 19:12
-
-
Save bil-bas/3049003 to your computer and use it in GitHub Desktop.
programatically define a method that accepts a block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test | |
def self.define_me_a_method(name) | |
self.send(:define_method, name, proc { |&block| | |
block.call | |
}) | |
end | |
define_me_a_method 'awesome' | |
end | |
puts Test.new.awesome do | |
'hello' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment