Class: Isomorphic::HashWithIndifferentAccess
- Inherits:
-
ActiveSupport::HashWithIndifferentAccess
- Object
- ActiveSupport::HashWithIndifferentAccess
- Isomorphic::HashWithIndifferentAccess
- Defined in:
- lib/isomorphic/hash_with_indifferent_access.rb
Overview
Implements a hash where keys :foo
, “foo” and Foo
are considered to be the same.
Instance Attribute Summary collapse
-
#inflector ⇒ Object
readonly
Returns the value of attribute inflector.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Same as Hash#[] where the key passed as argument can be either a string, a symbol or a class.
-
#assoc(key) ⇒ Array<Object>?
Same as Hash#assoc where the key passed as argument can be either a string, a symbol or a class.
-
#dig(*args) ⇒ Object?
Same as Hash#dig where the key passed as argument can be either a string, a symbol or a class.
-
#initialize(inflector, constructor = {}) ⇒ HashWithIndifferentAccess
constructor
Default constructor.
Constructor Details
#initialize(inflector, constructor = {}) ⇒ HashWithIndifferentAccess
Default constructor.
15 16 17 18 19 |
# File 'lib/isomorphic/hash_with_indifferent_access.rb', line 15 def initialize(inflector, constructor = {}) @inflector = inflector super(constructor) end |
Instance Attribute Details
#inflector ⇒ Object (readonly)
Returns the value of attribute inflector.
8 9 10 |
# File 'lib/isomorphic/hash_with_indifferent_access.rb', line 8 def inflector @inflector end |
Instance Method Details
#[](key) ⇒ Object
Same as Hash#[] where the key passed as argument can be either a string, a symbol or a class.
26 27 28 |
# File 'lib/isomorphic/hash_with_indifferent_access.rb', line 26 def [](key) super(convert_key(key)) end |
#assoc(key) ⇒ Array<Object>?
Same as Hash#assoc where the key passed as argument can be either a string, a symbol or a class.
35 36 37 |
# File 'lib/isomorphic/hash_with_indifferent_access.rb', line 35 def assoc(key) super(convert_key(key)) end |
#dig(*args) ⇒ Object?
Same as Hash#dig where the key passed as argument can be either a string, a symbol or a class.
45 46 47 48 |
# File 'lib/isomorphic/hash_with_indifferent_access.rb', line 45 def dig(*args) args[0] = convert_key(args[0]) if args.size > 0 super(*args) end |