Sha256: b9815ea0633dd77a89369464638cbdb0d8df25c759d44d2539ffb27134ac4751

Contents?: true

Size: 531 Bytes

Versions: 13

Compression:

Stored size: 531 Bytes

Contents

module Grape
  module Extensions
    module DeepHashWithIndifferentAccess
      def self.deep_hash_with_indifferent_access(object)
        case object
        when ::Hash
          object.inject(::ActiveSupport::HashWithIndifferentAccess.new) do |new_hash, (key, value)|
            new_hash.merge!(key => deep_hash_with_indifferent_access(value))
          end
        when ::Array
          object.map { |element| deep_hash_with_indifferent_access(element) }
        else
          object
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.2.5/lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.2.5 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.2.4 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.2.3 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.2.2 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.2.1 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.2.0 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.1.0 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.0.3 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.0.2 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.0.1 lib/grape/extensions/deep_hash_with_indifferent_access.rb
grape-1.0.0 lib/grape/extensions/deep_hash_with_indifferent_access.rb