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
cfoundry-1.1.0.rc4 lib/cfoundry/chatty_hash.rb
cfoundry-1.1.0.rc3 lib/cfoundry/chatty_hash.rb
cfoundry-1.1.0.rc2 lib/cfoundry/chatty_hash.rb
cfoundry-1.1.0.rc1 lib/cfoundry/chatty_hash.rb
static-1.0.3 vendor/cfoundry-0.5.2/lib/cfoundry/chatty_hash.rb
cfoundry-1.0.0 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc15 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc14 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc13 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc12 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc11 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc10 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc9 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc8 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc6 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc5 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc4 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc3 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc2 lib/cfoundry/chatty_hash.rb
cfoundry-0.7.0.rc1 lib/cfoundry/chatty_hash.rb