Sha256: 731d7beee570d39ced264a8447495dc1b7e73405dd4b93dba30173204f15db23

Contents?: true

Size: 475 Bytes

Versions: 6

Compression:

Stored size: 475 Bytes

Contents

require 'concurrent'

module Tracebin
  class Storage
    attr_reader :values

    def initialize
      @values = Concurrent::Array.new
    end

    def add(payload)
      @values << payload
    end
    alias_method :<<, :add

    def add_payload(payload)
      @values += payload if payload.is_a?(Array)
    end

    def unload
      duplicate_values = @values.dup
      @values.clear
      duplicate_values
    end

    def unloaded?
      @values.empty?
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tracebin-0.0.13 lib/tracebin/storage.rb
tracebin-0.0.12 lib/tracebin/storage.rb
tracebin-0.0.11 lib/tracebin/storage.rb
tracebin-0.0.10 lib/tracebin/storage.rb
tracebin-0.0.9 lib/tracebin/storage.rb
tracebin-0.0.8 lib/tracebin/storage.rb