Sha256: 1515034860c3ea0c89cdecfa7159820908bbd2174c3f7fd28ac4c48f2ba0ff7e

Contents?: true

Size: 473 Bytes

Versions: 1

Compression:

Stored size: 473 Bytes

Contents

require 'concurrent'

module Vizsla
  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

1 entries across 1 versions & 1 rubygems

Version Path
tracebin-0.0.7 lib/vizsla/storage.rb