Created
October 7, 2013 14:36
-
-
Save hltbra/6869053 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 Context | |
| def self.path(fname) | |
| puts "Creating file #{fname}" | |
| end | |
| end | |
| def template(filename, &block) | |
| context = Class.new(Context) | |
| context.class_eval(&block) | |
| context | |
| end | |
| template("/tmp/foo") do | |
| path "/tmp/foo.txt" | |
| end | |
| # output: | |
| # Creating file /tmp/foo.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment