Module: Traject::Hashie::IndifferentAccessFix

Defined in:
lib/traject/hashie/indifferent_access_fix.rb

Overview

Backporting fix from https://github.com/intridea/hashie/commit/a82c594710e1bc9460d3de4d2989cb700f4c3c7f into Hashie.

This makes merge(ordinary_hash) on a Hash that has IndifferentAccess included work, without raising. Which we needed.

As of this writing that fix is not available in a Hashie release, if it becomes so later than this monkey-patch may no longer be required, we can just depend on fixed version.

See also https://github.com/intridea/hashie/issues/451

Instance Method Summary collapse

Instance Method Details

#merge(*args) ⇒ Object


16
17
18
19
20
# File 'lib/traject/hashie/indifferent_access_fix.rb', line 16

def merge(*args)
  result = super
  ::Hashie::Extensions::IndifferentAccess.inject!(result) if hash_lacking_indifference?(result)
  result.convert!
end