diff options
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/ordered_hash.rb | 10 |
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 |