Sha256: e868bafd50d8ba4e15177b9daa418f18df44a5c615185ad796764d7c915a8168

Contents?: true

Size: 423 Bytes

Versions: 2

Compression:

Stored size: 423 Bytes

Contents

# frozen_string_literal: true

module Micro
  module Attributes
    module Utils
      def self.stringify_hash_keys(arg)
        hash = Kind::Of.(::Hash, arg)

        return hash if hash.empty?

        if hash.respond_to?(:transform_keys)
          hash.transform_keys { |key| key.to_s }
        else
          hash.each_with_object({}) { |(key, val), memo| memo[key.to_s] = val }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
u-attributes-2.0.1 lib/micro/attributes/utils.rb
u-attributes-2.0.0 lib/micro/attributes/utils.rb