Last active
December 20, 2016 02:11
-
-
Save thiagoa/37ffd84be4f86ecb2e3b23bc4d3b4072 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ModuleGenerator < Module | |
def build_methods(methods) | |
module_eval do | |
methods.each do |method| | |
define_method(method) do | |
puts "#{method} was defined in the instance methods" | |
end | |
end | |
end | |
end | |
end | |
OneTwoThree = ModuleGenerator.new | |
OneTwoThree.build_methods(%i(one two three)) | |
# Now we can include OneTwoThree somewhere |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment