Class: KnapsackPro::QueueAllocator::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/knapsack_pro/queue_allocator.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, response) ⇒ Batch

Returns a new instance of Batch.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
# File 'lib/knapsack_pro/queue_allocator.rb', line 8

def initialize(connection, response)
  @connection = connection
  @response = response

  raise ArgumentError.new(connection.response) if connection.errors?
end

Instance Method Details

#connection_failed?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/knapsack_pro/queue_allocator.rb', line 22

def connection_failed?
  !connection.success?
end

#queue_exists?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/knapsack_pro/queue_allocator.rb', line 15

def queue_exists?
  raise "Connection failed. Please report this as a bug: #{KnapsackPro::Urls::SUPPORT}" if connection_failed?
  return false if connection.api_code == KnapsackPro::Client::API::V1::Queues::CODE_ATTEMPT_CONNECT_TO_QUEUE_FAILED

  true
end

#test_filesObject



26
27
28
# File 'lib/knapsack_pro/queue_allocator.rb', line 26

def test_files
  response.fetch('test_files')
end