100% free for Open Source, forever. Get another set of eyes on your code.

100% free for Open Source, forever. Get another set of eyes on your code.

6c7dfadd
A

Hash

Updated more than 3 months ago.

No issues here.

Congrats! Give yourself time to reflect on your awesome coding skillz.

class Hash
  def symbolize
    Hash.symbolize_hash(self)
  end

  def self.symbolize_hash(obj)
    case obj
    when Array
      obj.each_with_object([]) do |val, res|
        res << case val
               when Hash, Array then symbolize_hash(val)
               when String      then val.to_sym
               else val
               end
      end
    when Hash
      obj.each_with_object({}) do |(key, val), res|
        nkey = key.is_a?(String) ? key.to_sym : key
        nval = case val
               when Hash, Array then symbolize_hash(val)
               when String      then val.to_sym
               else val
               end
        res[nkey] = nval
      end
    else
      obj
    end
  end
end
23
Complexity
0
Duplication
30
Lines
2
Methods
11.3
Complexity / M
0
Churn
29
Lines of Code
15
LOC / Method