summaryrefslogtreecommitdiff
path: root/lib/hashie/mash.rb
diff options
context:
space:
mode:
authorKoichi ITO <koic.ito@gmail.com>2020-01-18 00:42:12 +0900
committerKoichi ITO <koic.ito@gmail.com>2020-01-18 00:58:17 +0900
commit0dde4b4e3055ca918651f974b055e2cf7447fdba (patch)
treedc7b559682834249173a3b7d62fd2b5c5b120098 /lib/hashie/mash.rb
parent7fa93b19a098f90019fbe336ffcae4c3dbe4f54f (diff)
downloadhashie-0dde4b4e3055ca918651f974b055e2cf7447fdba.tar.gz
Suppress a Ruby's warning when using Ruby 2.6.0+
This PR suppresses the following warning that `deep_merge` method and `deep_update` method are defined twice when using Ruby 2.6.0+. ```console % bundle exec rake (snip) /Users/koic/src/github.com/hahie/hashie/lib/hashie/mash.rb:226: warning: method redefined; discarding old deep_merge /Users/koic/src/github.com/hahie/hashie/lib/hashie/mash.rb:212: warning: previous definition of deep_merge was here /Users/koic/src/github.com/hahie/hashie/lib/hashie/mash.rb:232: warning: method redefined; discarding old deep_update /Users/koic/src/github.com/hahie/hashie/lib/hashie/mash.rb:218: warning: previous definition of deep_update was here ```
Diffstat (limited to 'lib/hashie/mash.rb')
-rw-r--r--lib/hashie/mash.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/hashie/mash.rb b/lib/hashie/mash.rb
index 194a6f8..96b24c9 100644
--- a/lib/hashie/mash.rb
+++ b/lib/hashie/mash.rb
@@ -207,20 +207,7 @@ module Hashie
alias include? key?
alias member? key?
- # Performs a deep_update on a duplicate of the
- # current mash.
- def deep_merge(other_hash, &blk)
- dup.deep_update(other_hash, &blk)
- end
-
- # Recursively merges this mash with the passed
- # in hash, merging each hash in the hierarchy.
- def deep_update(other_hash, &blk)
- _deep_update(other_hash, &blk)
- self
- end
-
- with_minimum_ruby('2.6.0') do
+ if with_minimum_ruby?('2.6.0')
# Performs a deep_update on a duplicate of the
# current mash.
def deep_merge(*other_hashes, &blk)
@@ -235,6 +222,19 @@ module Hashie
end
self
end
+ else
+ # Performs a deep_update on a duplicate of the
+ # current mash.
+ def deep_merge(other_hash, &blk)
+ dup.deep_update(other_hash, &blk)
+ end
+
+ # Recursively merges this mash with the passed
+ # in hash, merging each hash in the hierarchy.
+ def deep_update(other_hash, &blk)
+ _deep_update(other_hash, &blk)
+ self
+ end
end
# Alias these lexically so they get the correctly defined