Skip to content

Instantly share code, notes, and snippets.

@bradstewart
Created February 6, 2015 00:10
Show Gist options
  • Save bradstewart/4c824b0c41ba7f271eac to your computer and use it in GitHub Desktop.
Save bradstewart/4c824b0c41ba7f271eac to your computer and use it in GitHub Desktop.
Add attributes to instance
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