Sha256: 930d6a826ea5fa3a884b5e28b4aa533d1d4bf6a9c38864a27582b44a3129e84c

Contents?: true

Size: 416 Bytes

Versions: 8

Compression:

Stored size: 416 Bytes

Contents

# frozen_string_literal: true

module Totoro
  class Utils
    def underscore_hash_keys(value)
      case value
      when Array
        value.map { |v| underscore_hash_keys(v) }
      when Hash
        Hash[value.map { |k, v| [underscorize(k), underscore_hash_keys(v)] }]
      else
        value
      end
    end

    private

    def underscorize(hash_key)
      hash_key.to_s.underscore.to_sym
    end
  end
end

Version data entries

8 entries across 7 versions & 1 rubygems

Version Path
totoro-1.0.7 lib/totoro/utils.rb
totoro-1.0.6 lib/totoro/utils.rb
totoro-1.0.6 pkg/totoro-1.0.5/lib/totoro/utils.rb
totoro-1.0.5 lib/totoro/utils.rb
totoro-1.0.4 lib/totoro/utils.rb
totoro-1.0.3 lib/totoro/utils.rb
totoro-1.0.2 lib/totoro/utils.rb
totoro-1.0.1 lib/totoro/utils.rb