Created
April 24, 2014 16:16
-
-
Save fj/11260367 to your computer and use it in GitHub Desktop.
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
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