Skip to content

Instantly share code, notes, and snippets.

@hltbra
Created October 7, 2013 14:36
Show Gist options
  • Select an option

  • Save hltbra/6869053 to your computer and use it in GitHub Desktop.

Select an option

Save hltbra/6869053 to your computer and use it in GitHub Desktop.
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