hashie/hashie

`Hashie::Array` converted to `Array` and breaking `#dig`

PashaLVWD opened this issue · 2 comments

2.6.3 :027 > RUBY_VERSION
 => "2.6.3"
2.6.3 :028 > Rails.version
 => "5.2.3"
2.6.3 :029 > Hashie::VERSION
 => "4.0.0"
2.6.3 :030 > hash = {'alphabet'=>{'first_three'=>['a','b','c']}}
 => {"alphabet"=>{"first_three"=>["a", "b", "c"]}}
2.6.3 :031 > hash.dig('alphabet', 'first_three').class
 => Array
2.6.3 :032 > hash.dig('alphabet', 'first_three', 0)
 => "a"
2.6.3 :033 > hashie_mash = Hashie::Mash.new(hash)
 => #<Hashie::Mash alphabet=#<Hashie::Mash first_three=#<Hashie::Array ["a", "b", "c"]>>>
2.6.3 :034 > hashie_mash.dig('alphabet', 'first_three').class
 => Hashie::Array
2.6.3 :035 > hashie_mash.dig('alphabet', 'first_three', 0)
 => "a"
2.6.3 :036 > hashie_mash['alphabet'] = hashie_mash['alphabet']
 => #<Hashie::Mash first_three=#<Hashie::Array ["a", "b", "c"]>>
2.6.3 :037 > hashie_mash.dig('alphabet', 'first_three').class
 => Array
2.6.3 :038 > hashie_mash.dig('alphabet', 'first_three', 0)
Traceback (most recent call last):
        1: from (irb):38
TypeError (no implicit conversion of String into Integer)

Looks like a problem. I suggest making a pull request with a spec, first.

Thanks @michaelherold for the fix in #505.