Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/insensitive_hash.rb

Direct Known Subclasses

InsensitiveHash

Instance Method Summary collapse

Instance Method Details

#insensitive(options = {}) ⇒ InsensitiveHash

Parameters:

  • options (Hash) (defaults to: {})

    Options

Options Hash (options):

  • :safe (Boolean)

    Whether to detect key clash on merge

  • :encoder (Proc)

    Key encoding Proc

Returns:



9
10
11
12
13
14
15
16
17
18
# File 'lib/insensitive_hash.rb', line 9

def insensitive options = {}
  InsensitiveHash.new.tap do |ih|
    ih.safe         = options[:safe] if options.has_key?(:safe)
    ih.encoder      = options[:encoder] if options.has_key?(:encoder)
    ih.default      = self.default
    ih.default_proc = self.default_proc if self.default_proc

    ih.merge_recursive!(self)
  end
end