Sha256: 3bda77954416e90daced013279c5653f6cd5e53c0fe95481763d2344c1a7100c

Contents?: true

Size: 357 Bytes

Versions: 9

Compression:

Stored size: 357 Bytes

Contents

module Pallets
  # Hash-like class that additionally holds a buffer for all write operations
  # that occur after initialization
  class Context < Hash
    def []=(key, value)
      buffer[key] = value
      super
    end

    def merge!(other_hash)
      buffer.merge!(other_hash)
      super
    end

    def buffer
      @buffer ||= {}
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pallets-0.11.0 lib/pallets/context.rb
pallets-0.10.0 lib/pallets/context.rb
pallets-0.9.0 lib/pallets/context.rb
pallets-0.8.0 lib/pallets/context.rb
pallets-0.7.0 lib/pallets/context.rb
pallets-0.6.0 lib/pallets/context.rb
pallets-0.5.1 lib/pallets/context.rb
pallets-0.5.0 lib/pallets/context.rb
pallets-0.4.0 lib/pallets/context.rb