diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/reverse_merge.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/reverse_merge.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb index 01863a162b..63b4ba49e9 100644 --- a/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +++ b/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb @@ -3,12 +3,23 @@ class Hash # # options = options.reverse_merge(:size => 25, :velocity => 10) # +<<<<<<< HEAD + # The default <tt>:size</tt> and <tt>:velocity</tt> are only set if the +options+ hash passed in doesn't already + # have the respective key. + # + # As contrast, using Ruby's built in <tt>merge</tt> would require writing the following: + # + # def setup(options = {}) + # options = { :size => 25, :velocity => 10 }.merge(options) + # end +======= # is equivalent to # # options = {:size => 25, :velocity => 10}.merge(options) # # This is particularly useful for initializing an options hash # with default values. +>>>>>>> 20768176292cbcb883ab152b4aa9ed8c664771cd def reverse_merge(other_hash) other_hash.merge(self) end |