Created
January 26, 2015 18:26
-
-
Save fgarcia/0f566ea9313794e19db0 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 Foo | |
def self.macros(&block) | |
mod = Module.new | |
mod.module_eval do | |
ANSWER = 42 | |
end | |
self.const_set(:Macros, mod) | |
Macros.module_eval do | |
module_eval &block | |
end | |
end | |
macros do | |
Point = Struct.new :x, :y | |
Value = 5 | |
def self.bar | |
"bar" | |
end | |
def foo | |
"foo" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment