Module: Configurable::IndifferentAccess
- Defined in:
- lib/configurable/indifferent_access.rb
Overview
Implements AGET and ASET methods that symbolize string keys, in effect producing indifferent access. IndifferentAccess is intended to extend a Hash.
Note that the indifference produced by this module is very thin indeed. Strings may still be used as keys through store/fetch, and existing string keys are not changed in any way. Nonetheless, these methods are sufficient for Configurable and DelegateHash.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Symbolizes string keys and calls super.
-
#[]=(key, value) ⇒ Object
Symbolizes string keys and calls super.
-
#dup ⇒ Object
Ensures duplicates use indifferent access.
Instance Method Details
#[](key) ⇒ Object
Symbolizes string keys and calls super.
14 15 16 |
# File 'lib/configurable/indifferent_access.rb', line 14 def [](key) super(convert(key)) end |
#[]=(key, value) ⇒ Object
Symbolizes string keys and calls super.
19 20 21 |
# File 'lib/configurable/indifferent_access.rb', line 19 def []=(key, value) super(convert(key), value) end |
#dup ⇒ Object
Ensures duplicates use indifferent access.
24 25 26 |
# File 'lib/configurable/indifferent_access.rb', line 24 def dup super().extend IndifferentAccess end |