This project is archived and is in readonly mode.

#4838 ✓committed
Paul Mucur

[PATCH] Add Block Support to ActiveSupport OrderedHash merge

Reported by Paul Mucur | June 12th, 2010 @ 12:15 AM

ActiveSupport's OrderedHash's implementation of merge and merge! does not support passing a block as per the standard library (c.f. )

The attached patch adds support to match the standard library's method signature:

hsh.merge(other_hash){|key, oldval, newval| block} → a_hash

Tests are also included.

This makes it possible to effectively map over an OrderedHash without turning it into an array by merging it with itself:

a =
a["age"] = 1
a["height"] = 15
a.merge(a) { |k, v| v * 2 }
# => #<OrderedHash {"height"=>30, "age"=>2}>

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket

Referenced by