aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/ordered_hash.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/ordered_hash.rb')
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb
index e1a2866863..eda33f827e 100644
--- a/activesupport/lib/active_support/ordered_hash.rb
+++ b/activesupport/lib/active_support/ordered_hash.rb
@@ -130,12 +130,16 @@ module ActiveSupport
end
def merge!(other_hash)
- other_hash.each {|k,v| self[k] = v }
+ if block_given?
+ other_hash.each {|k,v| self[k] = yield(k, self[k], v) }
+ else
+ other_hash.each {|k,v| self[k] = v }
+ end
self
end
- def merge(other_hash)
- dup.merge!(other_hash)
+ def merge(other_hash, &block)
+ dup.merge!(other_hash, &block)
end
# When replacing with another hash, the initial order of our keys must come from the other hash -ordered or not.