Created
June 18, 2009 10:56
-
-
Save methodmissing/131847 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ReverseMerge | |
| # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. | |
| def reverse_merge(other_hash) | |
| other_hash.merge(self) | |
| end | |
| # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. | |
| # Modifies the receiver in place. | |
| def reverse_merge!(other_hash) | |
| replace(reverse_merge(other_hash)) | |
| end | |
| alias_method :reverse_update, :reverse_merge! | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment