class Longleaf::CaseInsensitiveHash
Hash subclass which provides case insensitive keys, where keys are always downcased.
Public Instance Methods
[](key)
click to toggle source
Calls superclass method
# File lib/longleaf/helpers/case_insensitive_hash.rb, line 4 def [](key) super _insensitive(key) end
[]=(key, value)
click to toggle source
Calls superclass method
# File lib/longleaf/helpers/case_insensitive_hash.rb, line 8 def []=(key, value) super _insensitive(key), value end
delete(key)
click to toggle source
Calls superclass method
# File lib/longleaf/helpers/case_insensitive_hash.rb, line 12 def delete(key) super _insensitive(key) end
encode_with(coder)
click to toggle source
Cause this hash to serialize as a regular hash to avoid deserialization failures
# File lib/longleaf/helpers/case_insensitive_hash.rb, line 29 def encode_with coder coder.represent_map nil, self end
has_key?(key)
click to toggle source
Calls superclass method
# File lib/longleaf/helpers/case_insensitive_hash.rb, line 16 def has_key?(key) super _insensitive(key) end
merge(other_hash)
click to toggle source
Calls superclass method
# File lib/longleaf/helpers/case_insensitive_hash.rb, line 20 def merge(other_hash) super other_hash.map {|k, v| [_insensitive(k), v] }.to_h end
merge!(other_hash)
click to toggle source
Calls superclass method
# File lib/longleaf/helpers/case_insensitive_hash.rb, line 24 def merge!(other_hash) super other_hash.map {|k, v| [_insensitive(k), v] }.to_h end
Protected Instance Methods
_insensitive(key)
click to toggle source
# File lib/longleaf/helpers/case_insensitive_hash.rb, line 34 def _insensitive(key) key.respond_to?(:downcase) ? key.downcase : key end