Class: MJ_Hash
- Inherits:
-
Hash
- Object
- Hash
- MJ_Hash
- Defined in:
- lib/mj_hash.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(parent = nil, key = nil) ⇒ MJ_Hash
constructor
A new instance of MJ_Hash.
Constructor Details
#initialize(parent = nil, key = nil) ⇒ MJ_Hash
Returns a new instance of MJ_Hash.
2 3 4 5 6 |
# File 'lib/mj_hash.rb', line 2 def initialize(parent = nil, key = nil) @parent = parent @key = key super() end |
Instance Method Details
#[](key) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/mj_hash.rb', line 7 def [](key) if super(key) super(key) else MJ_Hash.new(self, key) end end |
#[]=(key, value) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/mj_hash.rb', line 14 def []=(key,value) val = super(key, value) if @parent @parent[@key] = self end val end |