Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

No need to use inject here.

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
commit 0876f39088e7f42f91948ad93659608e316ab9a4 1 parent 59296ab
@miloops miloops authored spastorino committed
Showing with 1 addition and 4 deletions.
  1. +1 −4 activeresource/lib/active_resource/base.rb
View
5 activeresource/lib/active_resource/base.rb
@@ -987,10 +987,7 @@ def initialize(attributes = {})
# 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.
Please sign in to comment.
Something went wrong with that request. Please try again.