Skip to content

Instantly share code, notes, and snippets.

@fj
Created April 24, 2014 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fj/11260367 to your computer and use it in GitHub Desktop.
Save fj/11260367 to your computer and use it in GitHub Desktop.
def with_model(m, &block)
w = Object.new
w.define_singleton_method :model do
m
end
w.instance_eval &block
end
def property(name)
puts model.to_s + name.to_s
end
with_model :foo do
property :bar # want "foobar"
property :baz # want "foobaz"
# ... many `property` invocations
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment