Sha256: 4403f125ca4a10dde2177a3b7c4974e011e95f67bf8010c133708a01eb67a7e7

Contents?: true

Size: 355 Bytes

Versions: 17

Compression:

Stored size: 355 Bytes

Contents

class Symbolizer
  def self.recursive_symbolize(hash)
    {}.tap do |h|
      hash.each { |key, value| h[key.to_sym] = self.map_value(value) }
    end
  end

  private

  def self.map_value(thing)
    case thing
    when Hash
      self.recursive_symbolize(thing)
    when Array
      thing.map { |v| map_value(v) }
    else
      thing
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
restpack_serializer-0.6.2 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.6.1 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.10 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.9 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.8 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.7 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.6 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.5 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.4 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.3 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.2 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.1 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.5.0 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.4.28 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.4.27 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.4.26 lib/restpack_serializer/serializable/symbolizer.rb
restpack_serializer-0.4.25 lib/restpack_serializer/serializable/symbolizer.rb