Created
July 29, 2013 09:00
-
-
Save porras/6103082 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class FancyDSL | |
| def initialize(&block) | |
| instance_eval(&block) | |
| end | |
| def setup(value) | |
| @setup = value | |
| end | |
| end | |
| f = FancyDSL.new do | |
| setup :wadus | |
| end | |
| puts f.inspect | |
| class Client | |
| def initialize(value) | |
| @value = value | |
| end | |
| def do_something | |
| f = FancyDSL.new do | |
| setup @value | |
| end | |
| puts f.inspect | |
| end | |
| end | |
| c = Client.new(:wadus) | |
| c.do_something |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment