Sha256: d4742e82bffaf336d82740fc688252fcb50b17a73a3562cf1e3712158c3133dc

Contents?: true

Size: 724 Bytes

Versions: 22

Compression:

Stored size: 724 Bytes

Contents

module RailsAdmin
  class HashHelper
    def self.symbolize(obj)
      case obj
      when Array
        obj.each_with_object([]) do |val, res|
          res << case val
                 when Hash, Array then symbolize(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(val)
                 when String      then val.to_sym
                 else val
                 end
          res[nkey] = nval
        end
      else
        obj
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
rails_admin-2.3.1 lib/rails_admin/support/hash_helper.rb
rails_admin-2.3.0 lib/rails_admin/support/hash_helper.rb
rails_admin-2.2.1 lib/rails_admin/support/hash_helper.rb
rails_admin-2.2.0 lib/rails_admin/support/hash_helper.rb
rails_admin-2.1.1 lib/rails_admin/support/hash_helper.rb
rails_admin-2.1.0 lib/rails_admin/support/hash_helper.rb
rails_admin-2.0.2 lib/rails_admin/support/hash_helper.rb
rails_admin-1.4.3 lib/rails_admin/support/hash_helper.rb
rails_admin-2.0.1 lib/rails_admin/support/hash_helper.rb
rails_admin-2.0.0 lib/rails_admin/support/hash_helper.rb
rails_admin-2.0.0.rc lib/rails_admin/support/hash_helper.rb
rails_admin-2.0.0.beta lib/rails_admin/support/hash_helper.rb
rails_admin-1.4.2 lib/rails_admin/support/hash_helper.rb
rails_admin-1.4.1 lib/rails_admin/support/hash_helper.rb
rails_admin-1.4.0 lib/rails_admin/support/hash_helper.rb
rails_admin-1.3.0 lib/rails_admin/support/hash_helper.rb
rails_admin-1.2.0 lib/rails_admin/support/hash_helper.rb
rails_admin-1.1.1 lib/rails_admin/support/hash_helper.rb
rails_admin-1.1.0 lib/rails_admin/support/hash_helper.rb
rails_admin-1.0.0 lib/rails_admin/support/hash_helper.rb