Skip to content

Instantly share code, notes, and snippets.

@fgarcia
Created January 26, 2015 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fgarcia/0f566ea9313794e19db0 to your computer and use it in GitHub Desktop.
Save fgarcia/0f566ea9313794e19db0 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