Class: Sinatra::StrongParameters::IndifferentHash

Inherits:
Hash
  • Object
show all
Includes:
Hashie::Extensions::IndifferentAccess
Defined in:
lib/sinatra/strong_parameters.rb

Direct Known Subclasses

Parameters

Instance Method Summary collapse

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