Class: Sinatra::StrongParameters::IndifferentHash
- Inherits:
-
Hash
- Object
- Hash
- Sinatra::StrongParameters::IndifferentHash
- Includes:
- Hashie::Extensions::IndifferentAccess
- Defined in:
- lib/sinatra/strong_parameters.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(attributes = nil) ⇒ IndifferentHash
constructor
A new instance of IndifferentHash.
- #slice(*keys) ⇒ Object
Constructor Details
#initialize(attributes = nil) ⇒ IndifferentHash
Returns a new instance of IndifferentHash.
11 12 13 14 |
# File 'lib/sinatra/strong_parameters.rb', line 11 def initialize(attributes = nil) super update(attributes) unless attributes.nil? end |
Instance Method Details
#slice(*keys) ⇒ Object
16 17 18 19 |
# File 'lib/sinatra/strong_parameters.rb', line 16 def slice(*keys) keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true) keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if has_key?(k) } end |