Class: Rory::HashWithDubiousSemantics
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Rory::HashWithDubiousSemantics
- Defined in:
- lib/rory/hash_with_dubious_semantics.rb
Overview
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(hash) ⇒ HashWithDubiousSemantics
constructor
A new instance of HashWithDubiousSemantics.
- #inspect ⇒ Object
Constructor Details
#initialize(hash) ⇒ HashWithDubiousSemantics
Returns a new instance of HashWithDubiousSemantics.
10 11 12 13 14 |
# File 'lib/rory/hash_with_dubious_semantics.rb', line 10 def initialize(hash) fail ArgumentError unless hash.is_a?(Hash) hash_with_no_symbols = convert_hash(hash) super( hash_with_no_symbols ) end |
Instance Method Details
#[](key) ⇒ Object
16 17 18 19 |
# File 'lib/rory/hash_with_dubious_semantics.rb', line 16 def [](key) actual_key = convert_key(key) __getobj__[actual_key] end |
#[]=(key, value) ⇒ Object
21 22 23 24 25 |
# File 'lib/rory/hash_with_dubious_semantics.rb', line 21 def []=(key, value) actual_key = convert_key(key) new_value = convert_value(value) __getobj__[actual_key] = new_value end |
#inspect ⇒ Object
27 28 29 |
# File 'lib/rory/hash_with_dubious_semantics.rb', line 27 def inspect "#<#{self.class.name} @hash=#{super}>" end |