Skip to content

Instantly share code, notes, and snippets.

@Aethelflaed
Forked from fgarcia/gist:0f566ea9313794e19db0
Last active August 29, 2015 14:14
Show Gist options
  • Save Aethelflaed/97f60fad28fb385d8d51 to your computer and use it in GitHub Desktop.
Save Aethelflaed/97f60fad28fb385d8d51 to your computer and use it in GitHub Desktop.
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