Sha256: 30c38a0b2d13eb39654de363bfbb29c331e8823017a3f37f604f4d0f42ff0c40

Contents?: true

Size: 606 Bytes

Versions: 53

Compression:

Stored size: 606 Bytes

Contents

module Relaton
  module Render
    module Utils
      def self.string_keys(hash)
        case hash
        when Hash
          hash.each_with_object({}) do |(k, v), ret|
            ret[k.to_s] = string_keys(v)
          end
        when Array then hash.map { |n| string_keys(n) }
        else hash
        end
      end

      def self.sym_keys(hash)
        case hash
        when Hash
          hash.each_with_object({}) do |(k, v), ret|
            ret[k.to_sym] = sym_keys(v)
          end
        when Array then hash.map { |n| sym_keys(n) }
        else hash
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
relaton-render-0.5.14 lib/relaton/render/utils/utils.rb
relaton-render-0.5.13 lib/relaton/render/utils/utils.rb
relaton-render-0.5.12 lib/relaton/render/utils/utils.rb
relaton-render-0.5.11 lib/relaton/render/utils/utils.rb
relaton-render-0.5.10 lib/relaton/render/utils/utils.rb
relaton-render-0.5.9 lib/relaton/render/utils/utils.rb
relaton-render-0.5.8 lib/relaton/render/utils/utils.rb
relaton-render-0.5.7 lib/relaton/render/utils/utils.rb
relaton-render-0.5.6 lib/relaton/render/utils/utils.rb
relaton-render-0.5.5 lib/relaton/render/utils/utils.rb
relaton-render-0.5.4 lib/relaton/render/utils/utils.rb
relaton-render-0.5.3 lib/relaton/render/utils/utils.rb
relaton-render-0.5.2 lib/relaton/render/utils/utils.rb
relaton-render-0.5.1 lib/relaton/render/utils/utils.rb
relaton-render-0.5.0 lib/relaton/render/utils/utils.rb
relaton-render-0.4.4 lib/relaton/render/utils/utils.rb
relaton-render-0.4.3 lib/relaton/render/utils/utils.rb
relaton-render-0.4.2 lib/relaton/render/utils/utils.rb
relaton-render-0.4.1 lib/relaton/render/utils/utils.rb
relaton-render-0.4.0 lib/relaton/render/utils/utils.rb