Sha256: fc80c96b5fc7755f74facf018480449baddb2c7fb96245121a3c2a864242b965

Contents?: true

Size: 637 Bytes

Versions: 158

Compression:

Stored size: 637 Bytes

Contents

module CFoundry
  class ChattyHash
    include Enumerable

    def initialize(callback, hash = {})
      @callback = callback
      @hash = hash
    end

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

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

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

    def delete(key)
      value = @hash.delete(key)
      @callback.call(self)
      value
    end

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

    def to_hash
      @hash
    end

    def to_s
      @hash.to_s
    end

    def inspect
      @hash.inspect
    end
  end
end

Version data entries

158 entries across 158 versions & 5 rubygems

Version Path
new_cfoundry-4.9.4 lib/cfoundry/chatty_hash.rb
new_cfoundry-4.9.3 lib/cfoundry/chatty_hash.rb
ncfoundry-4.9.4 lib/cfoundry/chatty_hash.rb
ncfoundry-4.9.3 lib/cfoundry/chatty_hash.rb
ncfoundry-4.9.2 lib/cfoundry/chatty_hash.rb
new_cfoundry-4.9.2 lib/cfoundry/chatty_hash.rb
new_cfoundry-4.9.1 lib/cfoundry/chatty_hash.rb
new_cfoundry-4.9.0 lib/cfoundry/chatty_hash.rb
new_cfoundry-4.8.3 lib/cfoundry/chatty_hash.rb
new_cfoundry-4.8.2 lib/cfoundry/chatty_hash.rb
cloulu-1.0.0 lib/cfoundry/chatty_hash.rb
cfoundry-4.7.2.rc1 lib/cfoundry/chatty_hash.rb
cloulu-0.7.0 lib/cfoundry/chatty_hash.rb
cfoundry-4.7.1 lib/cfoundry/chatty_hash.rb
cfoundry-4.7.1.rc1 lib/cfoundry/chatty_hash.rb
cloulu-0.6.6 lib/cfoundry/chatty_hash.rb
cfoundry-4.7.0 lib/cfoundry/chatty_hash.rb
cfoundry-4.6.3.rc3 lib/cfoundry/chatty_hash.rb
cloulu-0.6.5 lib/cfoundry/chatty_hash.rb
cfoundry-4.6.3.rc2 lib/cfoundry/chatty_hash.rb