Sha256: 808c080895fb83114edb6b2c7490f69775b0a1256ad717b1fe05555656b4de89
Contents?: true
Size: 763 Bytes
Versions: 19
Compression:
Stored size: 763 Bytes
Contents
module Pupa module Concerns # Adds private methods for changing hash keys to strings or symbols. module IndifferentAccess extend ActiveSupport::Concern private def transform_keys(object, meth) case object when Hash {}.tap do |hash| object.each do |key,value| hash[key.send(meth)] = transform_keys(value, meth) end end when Array object.map do |value| transform_keys(value, meth) end else object end end def symbolize_keys(object) transform_keys(object, :to_sym) end def stringify_keys(object) transform_keys(object, :to_s) end end end end
Version data entries
19 entries across 19 versions & 1 rubygems