From 4d3d06268068b3832dcf1e384ce6f95f1a759248 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Wed, 15 Jan 2020 13:12:09 +0900 Subject: Suppress an integer unification warning for Ruby 2.4.0+ This PR suppresss the following integer unification warning for Ruby 2.4.0+ ```console % ruby -v ruby 2.4.9p362 (2019-10-02 revision 67824) [x86_64-darwin17] % bundle exec rspec spec/hashie/extensions/deep_merge_spec.rb Hashie::Extensions::DeepMerge /Users/koic/src/github.com/hahie/hashie/lib/hashie/utils.rb:38: warning: constant ::Fixnum is deprecated /Users/koic/src/github.com/hahie/hashie/lib/hashie/utils.rb:38: warning: constant ::Bignum is deprecated ``` --- CHANGELOG.md | 1 + README.md | 4 ++-- lib/hashie/extensions/dash/property_translation.rb | 2 +- lib/hashie/utils.rb | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f1a5a9..d6ddaad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ scheme are considered to be bugs. * [#500](https://github.com/hashie/hashie/pull/500): Do not warn when setting Mash keys that look like underbang, bang, and query methods - [@michaelherold](https://github.com/michaelherold). * [#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). * Your contribution here. ### Security diff --git a/README.md b/README.md index f52f1f2..a098eae 100644 --- a/README.md +++ b/README.md @@ -897,7 +897,7 @@ class DataModelHash < Hashie::Dash end model = DataModelHash.new(id: '123', created: '2014-04-25 22:35:28') -model.id.class #=> Fixnum +model.id.class #=> Integer (Fixnum if you are using Ruby 2.3 or lower) model.created_at.class #=> Time ``` @@ -966,7 +966,7 @@ this will produce the following ```ruby result = Result.new(id: '123', creation_date: '2012-03-30 17:23:28') -result.id.class # => Fixnum +result.id.class # => Integer (Fixnum if you are using Ruby 2.3 or lower) result.created_at.class # => Time ``` diff --git a/lib/hashie/extensions/dash/property_translation.rb b/lib/hashie/extensions/dash/property_translation.rb index c0fd009..8149faa 100644 --- a/lib/hashie/extensions/dash/property_translation.rb +++ b/lib/hashie/extensions/dash/property_translation.rb @@ -35,7 +35,7 @@ module Hashie # end # # model = DataModelHash.new(id: '123', created: '2014-04-25 22:35:28') - # model.id.class #=> Fixnum + # model.id.class #=> Integer (Fixnum if you are using Ruby 2.3 or lower) # model.created_at.class #=> Time module PropertyTranslation def self.included(base) diff --git a/lib/hashie/utils.rb b/lib/hashie/utils.rb index 5b55b9a..9dc6294 100644 --- a/lib/hashie/utils.rb +++ b/lib/hashie/utils.rb @@ -34,10 +34,10 @@ module Hashie # @return [Array] def self.integer_classes @integer_classes ||= - if const_defined?(:Fixnum) - [Fixnum, Bignum] # rubocop:disable Lint/UnifiedInteger - else + if 0.class == Integer [Integer] + else + [Fixnum, Bignum] # rubocop:disable Lint/UnifiedInteger end end end -- cgit v1.2.1