Skip to content

Instantly share code, notes, and snippets.

@plexus
Created February 23, 2014 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plexus/9170061 to your computer and use it in GitHub Desktop.
Save plexus/9170061 to your computer and use it in GitHub Desktop.
$namespaces = []
def namespace(name, &blk)
$namespaces << Namespace.new(name, &blk)
end
class Namespace
def initialize(name, &blk)
@name = name
@thingies = []
instance_eval(&blk)
end
def thingy(name)
@thingies << name
end
end
namespace :foo do
thingy :bar
end
p $namespaces
# >> [#<Namespace:0x00000001ee9d40 @thingies=[:bar], @name=:foo>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment