Created
February 6, 2015 00:10
-
-
Save bradstewart/4c824b0c41ba7f271eac to your computer and use it in GitHub Desktop.
Add attributes to instance
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
def add_attributes(model, hash) | |
hash.each do |name, value| | |
setter_method = "#{name}=".to_sym | |
model.define_singleton_method(name.to_sym) | |
model.define_singleton_method(setter_method) | |
model.send(setter_method, value) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment