Sha256: d213047247ab4e7cac342f96947154e4679f00cd48502d536dc5a5f14c177c3a

Contents?: true

Size: 712 Bytes

Versions: 8

Compression:

Stored size: 712 Bytes

Contents

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rails_admin-0.7.0/lib/rails_admin/support/core_extensions.rb
rails_admin-0.7.0 lib/rails_admin/support/core_extensions.rb
rails_admin-0.6.8 lib/rails_admin/support/core_extensions.rb
rails_admin-0.6.7 lib/rails_admin/support/core_extensions.rb
rails_admin-0.6.6 lib/rails_admin/support/core_extensions.rb
rails_admin-0.6.5 lib/rails_admin/support/core_extensions.rb
rails_admin-0.6.4 lib/rails_admin/support/core_extensions.rb
rails_admin-0.6.3 lib/rails_admin/support/core_extensions.rb