Class: Typhoid::RequestQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/typhoid/request_queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target, hydra = nil) ⇒ RequestQueue

Returns a new instance of RequestQueue.



8
9
10
11
# File 'lib/typhoid/request_queue.rb', line 8

def initialize(target, hydra = nil)
  @target = target
  @hydra = hydra || Typhoeus::Hydra.new
end

Instance Attribute Details

#queueObject (readonly)

Returns the value of attribute queue.



5
6
7
# File 'lib/typhoid/request_queue.rb', line 5

def queue
  @queue
end

#targetObject

Returns the value of attribute target.



6
7
8
# File 'lib/typhoid/request_queue.rb', line 6

def target
  @target
end

Instance Method Details

#requestsObject



25
26
27
# File 'lib/typhoid/request_queue.rb', line 25

def requests
  @queue ||= []
end

#resource(name, req, &block) ⇒ Object



13
14
15
16
17
# File 'lib/typhoid/request_queue.rb', line 13

def resource(name, req, &block)
  @queue ||= []
  @queue << QueuedRequest.new(@hydra, name, req, @target)
  #@queue[name].on_complete &block if block != nil
end

#resource_with_target(name, req, target, &block) ⇒ Object



19
20
21
22
23
# File 'lib/typhoid/request_queue.rb', line 19

def resource_with_target(name, req, target, &block)
  @queue ||= []
  @queue << QueuedRequest.new(@hydra, name, req, target)
  #@queue[name].on_complete &block if block != nil
end

#runObject



29
30
31
# File 'lib/typhoid/request_queue.rb', line 29

def run
  @hydra.run
end