Class: Rack::Utils::KeySpaceConstrainedParams
- Inherits:
-
Object
- Object
- Rack::Utils::KeySpaceConstrainedParams
- Defined in:
- rack/rack/utils.rb
Instance Method Summary (collapse)
- - (void) [](key)
- - (void) []=(key, value)
-
- (KeySpaceConstrainedParams) initialize(limit = Utils.key_space_limit)
constructor
A new instance of KeySpaceConstrainedParams.
- - (Boolean) key?(key)
- - (void) to_params_hash
Constructor Details
- (KeySpaceConstrainedParams) initialize(limit = Utils.key_space_limit)
Returns a new instance of KeySpaceConstrainedParams
505 506 507 508 509 |
# File 'rack/rack/utils.rb', line 505 def initialize(limit = Utils.key_space_limit) @limit = limit @size = 0 @params = {} end |
Instance Method Details
- (void) [](key)
511 512 513 |
# File 'rack/rack/utils.rb', line 511 def [](key) @params[key] end |
- (void) []=(key, value)
515 516 517 518 519 |
# File 'rack/rack/utils.rb', line 515 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 |
- (Boolean) key?(key)
521 522 523 |
# File 'rack/rack/utils.rb', line 521 def key?(key) @params.key?(key) end |
- (void) to_params_hash
525 526 527 528 529 530 531 532 533 534 535 536 |
# File 'rack/rack/utils.rb', line 525 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 |