Sha256: a903c06b03f9f01ada3d2ed79f45410673b84b6f9daa0b84fb2b351644639873
Contents?: true
Size: 745 Bytes
Versions: 1
Compression:
Stored size: 745 Bytes
Contents
require 'json' # Inspired by # https://github.com/rails/rails/blob/v6.0.0/activesupport/lib/active_support/core_ext/hash/keys.rb#L116 module LedgerSync module Util module HashHelpers module_function def deep_symbolize_keys(hash) deep_transform_keys_in_object(hash) { |key| key.to_sym rescue key } end def deep_transform_keys_in_object(object, &block) case object when Hash object.each_with_object({}) do |(key, value), result| result[yield(key)] = deep_transform_keys_in_object(value, &block) end when Array object.map { |e| deep_transform_keys_in_object(e, &block) } else object end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ledger_sync-1.1.1 | lib/ledger_sync/util/hash_helpers.rb |