diff options
author | Daniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org> | 2020-01-20 15:29:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-20 15:29:53 -0500 |
commit | 505f0fed34fb9be70697a31787a238e297fbc3c7 (patch) | |
tree | dc7b559682834249173a3b7d62fd2b5c5b120098 /lib | |
parent | 7fa93b19a098f90019fbe336ffcae4c3dbe4f54f (diff) | |
parent | 0dde4b4e3055ca918651f974b055e2cf7447fdba (diff) | |
download | hashie-505f0fed34fb9be70697a31787a238e297fbc3c7.tar.gz |
Merge pull request #513 from koic/suppress_ruby_warning_for_ruby_2_6
Suppress a Ruby's warning when using Ruby 2.6.0+
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hashie/extensions/ruby_version_check.rb | 6 | ||||
-rw-r--r-- | lib/hashie/mash.rb | 28 |
2 files changed, 19 insertions, 15 deletions
diff --git a/lib/hashie/extensions/ruby_version_check.rb b/lib/hashie/extensions/ruby_version_check.rb index bcd3436..b287230 100644 --- a/lib/hashie/extensions/ruby_version_check.rb +++ b/lib/hashie/extensions/ruby_version_check.rb @@ -9,7 +9,11 @@ module Hashie module ClassMethods def with_minimum_ruby(version) - yield if RubyVersion.new(RUBY_VERSION) >= RubyVersion.new(version) + yield if with_minimum_ruby?(version) + end + + def with_minimum_ruby?(version) + RubyVersion.new(RUBY_VERSION) >= RubyVersion.new(version) end end end 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 |