aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/ordered_hash.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2010-06-13 06:37:54 +0200
committerXavier Noria <fxn@hashref.com>2010-06-13 06:37:54 +0200
commit36143d26cb841210b5f22aff4ed9c093a0554a1a (patch)
tree751e2da1787259986a93e50beee08cf6fab406cd /activesupport/lib/active_support/ordered_hash.rb
parent3359af63a518798ccc9c7f1c71e5507f6fe0d378 (diff)
downloadrails-36143d26cb841210b5f22aff4ed9c093a0554a1a.tar.gz
rails-36143d26cb841210b5f22aff4ed9c093a0554a1a.tar.bz2
rails-36143d26cb841210b5f22aff4ed9c093a0554a1a.zip
revises implementation of AS::OrderedHash#merge!
Diffstat (limited to 'activesupport/lib/active_support/ordered_hash.rb')
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb
index eda33f827e..cd450fd00f 100644
--- a/activesupport/lib/active_support/ordered_hash.rb
+++ b/activesupport/lib/active_support/ordered_hash.rb
@@ -130,10 +130,12 @@ module ActiveSupport
end
def merge!(other_hash)
- if block_given?
- other_hash.each {|k,v| self[k] = yield(k, self[k], v) }
- else
- other_hash.each {|k,v| self[k] = v }
+ other_hash.each do |k, v|
+ if block_given? && key?(k)
+ self[k] = yield k, self[k], v
+ else
+ self[k] = v
+ end
end
self
end