Sha256: 50b164d59fd0f2d0a12494c499b0b98eec7593c5503aa64b9e9e9a864f471b88

Contents?: true

Size: 385 Bytes

Versions: 3

Compression:

Stored size: 385 Bytes

Contents

# frozen_string_literal: true

class BasicSerializer
  class Hash < ::Hash
    def deep_stringify_keys
      transform_keys(&:to_s).transform_values do |value|
        case value
        when Hash then deep_stringify_keys(value)
        when Array then value.map { |item| item.is_a?(Hash) ? deep_stringify_keys(item) : item }
        else value
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
basic_serializer-0.1.8 lib/basic_serializer/hash.rb
basic_serializer-0.1.7 lib/basic_serializer/hash.rb
basic_serializer-0.1.6 lib/basic_serializer/hash.rb