8000 Suppress a Ruby's warning when using Ruby 2.6.0+ by koic · Pull Request #513 · hashie/hashie · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Suppress a Ruby's warning when using Ruby 2.6.0+ #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ scheme are considered to be bugs.
* [#510](https://github.com/hashie/hashie/pull/510): Ensure that `Hashie::Mash#compact` is only defined on Ruby version >= 2.4.0 - [@bobbymcwho](https://github.com/bobbymcwho).
* [#511](https://github.com/hashie/hashie/pull/511): Suppress keyword arguments warning for Ruby 2.7.0 - [@koic](https://github.com/koic).
* [#512](https://github.com/hashie/hashie/pull/512): Suppress an integer unification warning for using Ruby 2.4.0+ - [@koic](https://github.com/koic).
* [#513](https://github.com/hashie/hashie/pull/513): Suppress a Ruby's warning when using Ruby 2.6.0+ - [@koic](https://github.com/koic).
* Your contribution here.

### Security
Expand Down
6 changes: 5 additions & 1 deletion lib/hashie/extensions/ruby_version_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ def self.included(base)

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
Expand Down
28 changes: 14 additions & 14 deletions lib/hashie/mash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,7 @@ def key?(key)
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_u 7A11 pdate on a duplicate of the
# current mash.
def deep_merge(*other_hashes, &blk)
Expand All @@ -235,6 +222,19 @@ def deep_update(*other_hashes, &blk)
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
Expand Down
0