Skip to content

Instantly share code, notes, and snippets.

/dsl Secret

Created June 16, 2015 02:21
Show Gist options
  • Save anonymous/64efa3fc4c6114bba59f to your computer and use it in GitHub Desktop.
Save anonymous/64efa3fc4c6114bba59f to your computer and use it in GitHub Desktop.
DSL question
module DSL
def items
@items ||= []
end
def add
items << 'added'
end
end
module Implementor
extend DSL
@@name = self
def get_objects
@@name.instance_eval { items }
end
add
add
end
class Client
extend Implementor
get_objects.each do |item|
puts item.inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment