Created
May 26, 2009 13:18
-
-
Save eviltrout/118062 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 make_new(obj, hash) | |
new_ob = type.new | |
# Two approaches - 1st: You can use the array notation [] on an activerecord to use it like a hash | |
hash.each do {|key, value| new_ob[key] = value } | |
# Or you can send to the method using period: | |
hash.each do {|key, value| new_ob.send("#{key.to_s}=", value) } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment