Sha256: 27767e9734dc2a3b79c90398d92fc1bd7d955d64365e57f8134638da27bb0131

Contents?: true

Size: 553 Bytes

Versions: 32

Compression:

Stored size: 553 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
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
cfoundry-0.4.8 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.7 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.6 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.5 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.4 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.3 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.2 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.1 lib/cfoundry/chatty_hash.rb
cfoundry-0.4.0 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.61 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.60 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.59 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.58 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.57 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.56 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.55 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.54 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.53 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.52 lib/cfoundry/chatty_hash.rb
cfoundry-0.3.51 lib/cfoundry/chatty_hash.rb