Class: Typhoid::RequestQueue
- Inherits:
-
Object
- Object
- Typhoid::RequestQueue
- Defined in:
- lib/typhoid/request_queue.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(target, hydra = nil) ⇒ RequestQueue
constructor
A new instance of RequestQueue.
- #requests ⇒ Object
- #resource(name, req, &block) ⇒ Object
- #resource_with_target(name, req, target, &block) ⇒ Object
- #run ⇒ Object
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
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
5 6 7 |
# File 'lib/typhoid/request_queue.rb', line 5 def queue @queue end |
#target ⇒ Object
Returns the value of attribute target.
6 7 8 |
# File 'lib/typhoid/request_queue.rb', line 6 def target @target end |
Instance Method Details
#requests ⇒ Object
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 |
#run ⇒ Object
29 30 31 |
# File 'lib/typhoid/request_queue.rb', line 29 def run @hydra.run end |