HabitatMap/AirCasting

View on GitHub
lib/aircasting/deep_symbolize.rb

Summary

Maintainability
A
0 mins
Test Coverage
module AirCasting
  module DeepSymbolize
    def deep_symbolize(obj)
      if obj.respond_to?(:symbolize_keys)
        data = obj.symbolize_keys.map { |k, v| [k, deep_symbolize(v)] }
        Hash[data]
      elsif obj.respond_to?(:map)
        obj.map { |x| deep_symbolize(x) }
      else
        obj
      end
    end
  end
end