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-0.5.1.rc5 lib/cfoundry/chatty_hash.rb
cfoundry-0.5.1.rc4 lib/cfoundry/chatty_hash.rb
cfoundry-0.5.1.rc3 lib/cfoundry/chatty_hash.rb
cfoundry-0.5.1.rc2 lib/cfoundry/chatty_hash.rb
cfoundry-0.5.1.rc1 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.21 lib/cfoundry/chatty_hash.rb
cfoundry-0.5.0 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.19 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.18 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.17 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.16 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.15 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.14 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.13 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.12 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.11 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.10 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.9 lib/cfoundry/chatty_hash.rb