Sha256: 6a0793998879093427640c5756f05d73d382626bbfa9b275183e4e4a4f6e0710

Contents?: true

Size: 733 Bytes

Versions: 30

Compression:

Stored size: 733 Bytes

Contents

class Hash

  def symbolize
    Hash.symbolize_hash(self)
  end

  def self.symbolize_hash(obj)
    case obj
    when Array
      obj.inject([]){|res, val|
        res << case val
        when Hash, Array
          symbolize_hash(val)
        when String
          val.to_sym
        else
          val
        end
        res
      }
    when Hash
      obj.inject({}){|res, (key, val)|
        nkey = case key
        when String
          key.to_sym
        else
          key
        end
        nval = case val
        when Hash, Array
          symbolize_hash(val)
        when String
          val.to_sym
        else
          val
        end
        res[nkey] = nval
        res
      }
    else
      obj
    end
  end
end

Version data entries

30 entries across 30 versions & 5 rubygems

Version Path
rails_admin-0.6.0 lib/rails_admin/support/core_extensions.rb
rails_admin-0.5.0 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.9 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.8 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.7 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.6 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.5 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.4 lib/rails_admin/support/core_extensions.rb
rails_admin-lbgraham-0.4.2 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.3 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.2 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.1 lib/rails_admin/support/core_extensions.rb
rails_admin-0.4.0 lib/rails_admin/support/core_extensions.rb
rails_admin-0.3.0 lib/rails_admin/support/core_extensions.rb
rails_admin-0.2.0 lib/rails_admin/support/core_extensions.rb
rails_admin-0.1.2 lib/rails_admin/support/core_extensions.rb
rails_admin-0.1.1 lib/rails_admin/support/core_extensions.rb
rails_admin-0.1.0 lib/rails_admin/support/core_extensions.rb
rails_admin-0.0.5 lib/rails_admin/support/core_extensions.rb
rails_admin-0.0.4 lib/rails_admin/support/core_extensions.rb