aboutsummaryrefslogtreecommitdiffstats
path: root/activeresource/lib/active_resource
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-09-22 12:02:17 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2010-09-22 18:08:03 -0300
commit0876f39088e7f42f91948ad93659608e316ab9a4 (patch)
treeec4c0fe2dd329b5a8c670cd0d8bc4cb009f1606b /activeresource/lib/active_resource
parent59296ab26dc8518fb83f0015a3871936149b86da (diff)
downloadrails-0876f39088e7f42f91948ad93659608e316ab9a4.tar.gz
rails-0876f39088e7f42f91948ad93659608e316ab9a4.tar.bz2
rails-0876f39088e7f42f91948ad93659608e316ab9a4.zip
No need to use inject here.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activeresource/lib/active_resource')
-rw-r--r--activeresource/lib/active_resource/base.rb5
1 files changed, 1 insertions, 4 deletions
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 3241a161a9..3016f62b80 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -987,10 +987,7 @@ module ActiveResource
# not_ryan.hash # => {:not => "an ARes instance"}
def clone
# Clone all attributes except the pk and any nested ARes
- cloned = attributes.reject {|k,v| k == self.class.primary_key || v.is_a?(ActiveResource::Base)}.inject({}) do |attrs, (k, v)|
- attrs[k] = v.clone
- attrs
- end
+ cloned = Hash[attributes.reject {|k,v| k == self.class.primary_key || v.is_a?(ActiveResource::Base)}.map { |k, v| [k, v.clone] }]
# Form the new resource - bypass initialize of resource with 'new' as that will call 'load' which
# attempts to convert hashes into member objects and arrays into collections of objects. We want
# the raw objects to be cloned so we bypass load by directly setting the attributes hash.