Class: CFoundry::ChattyHash

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/cfoundry/chatty_hash.rb

Instance Method Summary collapse

Constructor Details

#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

#[](name) ⇒ Object



10
11
12
# File 'lib/cfoundry/chatty_hash.rb', line 10

def [](name)
  @hash[name]
end

#[]=(name, value) ⇒ Object



14
15
16
17
18
# File 'lib/cfoundry/chatty_hash.rb', line 14

def []=(name, value)
  @hash[name] = value
  @callback.call(self)
  value
end

#delete(key) ⇒ Object



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

#each(&blk) ⇒ Object



20
21
22
# File 'lib/cfoundry/chatty_hash.rb', line 20

def each(&blk)
  @hash.each(&blk)
end

#to_hashObject



34
35
36
# File 'lib/cfoundry/chatty_hash.rb', line 34

def to_hash
  @hash
end

#to_json(*args) ⇒ Object



30
31
32
# File 'lib/cfoundry/chatty_hash.rb', line 30

def to_json(*args)
  @hash.to_json(*args)
end