Parent

Rack::Utils::KeySpaceConstrainedParams

Public Class Methods

new(limit = Utils.key_space_limit) click to toggle source
# File lib/rack/utils.rb, line 492
def initialize(limit = Utils.key_space_limit)
  @limit  = limit
  @size   = 0
  @params = {}
end

Public Instance Methods

[](key) click to toggle source
# File lib/rack/utils.rb, line 498
def [](key)
  @params[key]
end
[]=(key, value) click to toggle source
# File lib/rack/utils.rb, line 502
def []=(key, value)
  @size += key.size if key && !@params.key?(key)
  raise RangeError, 'exceeded available parameter key space' if @size > @limit
  @params[key] = value
end
key?(key) click to toggle source
# File lib/rack/utils.rb, line 508
def key?(key)
  @params.key?(key)
end
to_params_hash() click to toggle source
# File lib/rack/utils.rb, line 512
def to_params_hash
  hash = @params
  hash.keys.each do |key|
    value = hash[key]
    if value.kind_of?(self.class)
      hash[key] = value.to_params_hash
    elsif value.kind_of?(Array)
      value.map! {|x| x.kind_of?(self.class) ? x.to_params_hash : x}
    end
  end
  hash
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.