Sha256: 9e8daec0ff121e89c337d9c558a9e84b68bd94d1d9d4f3997853cdfc795e4c46

Contents?: true

Size: 438 Bytes

Versions: 1

Compression:

Stored size: 438 Bytes

Contents

module Stomper
  class ReceiptHandlers
    def initialize
      @recps = {}
      @recp_lock = Mutex.new
    end

    def add(receipt_id, callback)
      @recp_lock.synchronize { @recps[receipt_id] = callback }
    end
    
    def size
      @recps.size
    end

    def perform(receipt)
      @recp_lock.synchronize do
        callback = @recps.delete(receipt.for)
        callback.call(receipt) if callback
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stomper-1.0.0 lib/stomper/receipt_handlers.rb