Sha256: dec3e33992d24265a6d413495dc35281c0a8a09182df65c471ea5ddf1762c0bd

Contents?: true

Size: 706 Bytes

Versions: 19

Compression:

Stored size: 706 Bytes

Contents

module Munge
  module Util
    class SymbolHash
      class << self
        def deep_convert(obj)
          if obj.is_a?(Hash)
            convert_hash(obj)
          elsif obj.is_a?(Array)
            obj.map do |i|
              deep_convert(i)
            end
          else
            obj
          end
        end

        private

        def convert_hash(obj)
          converted_hash = {}

          obj.each do |key, value|
            if key.is_a?(String) || key.is_a?(Symbol)
              converted_hash[key.to_sym] = deep_convert(value)
            else
              converted_hash[key] = value
            end
          end

          converted_hash
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
munge-0.19.0 lib/munge/util/symbol_hash.rb
munge-0.18.0 lib/munge/util/symbol_hash.rb
munge-0.17.0 lib/munge/util/symbol_hash.rb
munge-0.16.0 lib/munge/util/symbol_hash.rb
munge-0.15.1 lib/munge/util/symbol_hash.rb
munge-0.15.0 lib/munge/util/symbol_hash.rb
munge-0.14.0 lib/munge/util/symbol_hash.rb
munge-0.13.0 lib/munge/util/symbol_hash.rb
munge-0.12.0 lib/munge/util/symbol_hash.rb
munge-0.11.1 lib/munge/util/symbol_hash.rb
munge-0.11.0 lib/munge/util/symbol_hash.rb
munge-0.10.0 lib/munge/util/symbol_hash.rb
munge-0.9.0 lib/munge/util/symbol_hash.rb
munge-0.8.0 lib/munge/util/symbol_hash.rb
munge-0.7.1 lib/munge/util/symbol_hash.rb
munge-0.7.0 lib/munge/util/symbol_hash.rb
munge-0.6.0 lib/munge/util/symbol_hash.rb
munge-0.5.0 lib/munge/util/symbol_hash.rb
munge-0.5.0.beta1 lib/munge/util/symbol_hash.rb