Sha256: 6748dd124924d4979bd6f11c541ce51dc7fe1cd986c366c002f3fd2c750b4cf2

Contents?: true

Size: 496 Bytes

Versions: 7

Compression:

Stored size: 496 Bytes

Contents

class Localjob
  class Channel
    def shift
      queue = @queues.find { |q| q.size > 0 }
      return queue.shift
    end
  end

  class MockAdapter
    def initialize(name = 'default')
      @@queues ||= {}
      @name = name 
      @@queues[@name] ||= []
    end

    def receive
      @@queues[@name].shift
    end

    def send(message)
      @@queues[@name] << message
    end

    def size
      @@queues[@name].size
    end

    def destroy
      @@queues[@name] = nil
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
localjob-0.4.1 lib/localjob/mock_adapter.rb
localjob-0.4.0 lib/localjob/mock_adapter.rb
localjob-0.3.0 lib/localjob/mock_adapter.rb
localjob-0.2.0 lib/localjob/mock_adapter.rb
localjob-0.1.1 lib/localjob/mock_adapter.rb
localjob-0.1.0 lib/localjob/mock_adapter.rb
localjob-0.0.2 lib/localjob/mock_adapter.rb