Skip to content

Instantly share code, notes, and snippets.

@ahoward
ahoward / dsl.rb
Created November 8, 2012 18:45
this is how to build dsls that don't fuck the global namespace
# the entire concept of building a dsl means defining domain terms on an
# object, it's so much simpler to start with the dsl itself being a blank
# slate that simply relays certain methods to a scope
#
class DSL
instance_methods.each do |m|
undef_method m unless m[%r/\A__|\Aobject_id\Z/]
end