Permalink
Browse files

Make use of tap to return a previously used var

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent e107c20 commit ef5ae60a07c7d45855a9a2a4b695f153ef9faa79 @spastorino spastorino committed with josevalim Jul 21, 2010
Showing with 4 additions and 4 deletions.
  1. +4 −4 activerecord/lib/active_record/associations/association_collection.rb
@@ -397,10 +397,10 @@ def load_target
@target = find_target.map do |f|
i = @target.index(f)
if i
- t = @target.delete_at(i)
- keys = ["id"] + t.changes.keys + (f.attribute_names - t.attribute_names)
- t.attributes = f.attributes.except(*keys)
- t
+ @target.delete_at(i).tap do |t|
+ keys = ["id"] + t.changes.keys + (f.attribute_names - t.attribute_names)
+ t.attributes = f.attributes.except(*keys)
+ end
else
f
end

0 comments on commit ef5ae60

Please sign in to comment.