Class: CFoundry::ChattyHash
- Inherits:
-
Object
- Object
- CFoundry::ChattyHash
- Includes:
- Enumerable
- Defined in:
- lib/cfoundry/chatty_hash.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
- #delete(key) ⇒ Object
- #each(&blk) ⇒ Object
-
#initialize(callback, hash = {}) ⇒ ChattyHash
constructor
A new instance of ChattyHash.
- #inspect ⇒ Object
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
- #to_s ⇒ Object
Constructor Details
permalink #initialize(callback, hash = {}) ⇒ ChattyHash
Returns a new instance of ChattyHash.
5 6 7 8 |
# File 'lib/cfoundry/chatty_hash.rb', line 5 def initialize(callback, hash = {}) @callback = callback @hash = hash end |
Instance Method Details
permalink #[](name) ⇒ Object
[View source]
10 11 12 |
# File 'lib/cfoundry/chatty_hash.rb', line 10 def [](name) @hash[name] end |
permalink #[]=(name, value) ⇒ Object
[View source]
14 15 16 17 18 |
# File 'lib/cfoundry/chatty_hash.rb', line 14 def []=(name, value) @hash[name] = value @callback.call(self) value end |
permalink #delete(key) ⇒ Object
[View source]
24 25 26 27 28 |
# File 'lib/cfoundry/chatty_hash.rb', line 24 def delete(key) value = @hash.delete(key) @callback.call(self) value end |
permalink #each(&blk) ⇒ Object
[View source]
20 21 22 |
# File 'lib/cfoundry/chatty_hash.rb', line 20 def each(&blk) @hash.each(&blk) end |
permalink #inspect ⇒ Object
[View source]
42 43 44 |
# File 'lib/cfoundry/chatty_hash.rb', line 42 def inspect @hash.inspect end |
permalink #to_hash ⇒ Object
[View source]
34 35 36 |
# File 'lib/cfoundry/chatty_hash.rb', line 34 def to_hash @hash end |
permalink #to_json(*args) ⇒ Object
[View source]
30 31 32 |
# File 'lib/cfoundry/chatty_hash.rb', line 30 def to_json(*args) @hash.to_json(*args) end |
permalink #to_s ⇒ Object
[View source]
38 39 40 |
# File 'lib/cfoundry/chatty_hash.rb', line 38 def to_s @hash.to_s end |