Skip to content
Permalink
Browse files

Merge pull request #604 from kachick/hash-update

Hash#merge!, Hash#update
  • Loading branch information
alex committed Apr 11, 2013
2 parents c684219 + ef92287 commit 47a3a2bb6069ff3cd237207ff3142b32fa25255e
Showing with 2 additions and 10 deletions.
  1. +2 −0 lib-topaz/hash.rb
  2. +0 −2 spec/tags/core/hash/merge_tags.txt
  3. +0 −8 spec/tags/core/hash/update_tags.txt
@@ -50,6 +50,7 @@ def ==(other)
end

def merge!(other, &block)
raise RuntimeError.new("can't modify frozen #{self.class}") if frozen?
other = other.to_hash unless other.kind_of? Hash
if block
other.each do |key, val|
@@ -66,6 +67,7 @@ def merge!(other, &block)
end
self
end
alias update merge!

def merge(other, &block)
dup.merge! other, &block
@@ -1,3 +1 @@
fails:Hash#merge returns subclass instance for subclasses
fails:Hash#merge! checks frozen status before coercing an object with #to_hash
fails:Hash#merge! raises a RuntimeError on a frozen instance that would not be modified

This file was deleted.

0 comments on commit 47a3a2b

Please sign in to comment.