-
-
Save anonymous/64efa3fc4c6114bba59f to your computer and use it in GitHub Desktop.
DSL question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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