Class: Morpheus::RequestQueue
- Inherits:
-
Object
- Object
- Morpheus::RequestQueue
- Defined in:
- lib/morpheus/request_queue.rb
Class Method Summary collapse
- .enqueue(request) ⇒ Object
- .has_request?(request) ⇒ Boolean
- .hydra ⇒ Object
- .queue ⇒ Object
- .run! ⇒ Object
- .uncached_queue ⇒ Object
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RequestQueue
constructor
A new instance of RequestQueue.
Constructor Details
#initialize(app) ⇒ RequestQueue
Returns a new instance of RequestQueue.
4 5 6 |
# File 'lib/morpheus/request_queue.rb', line 4 def initialize(app) @app = app end |
Class Method Details
.enqueue(request) ⇒ Object
15 16 17 |
# File 'lib/morpheus/request_queue.rb', line 15 def enqueue(request) queue << request end |
.has_request?(request) ⇒ Boolean
37 38 39 |
# File 'lib/morpheus/request_queue.rb', line 37 def has_request?(request) queue.include?(request) end |
.hydra ⇒ Object
27 28 29 |
# File 'lib/morpheus/request_queue.rb', line 27 def hydra Configuration.hydra end |
.queue ⇒ Object
19 20 21 |
# File 'lib/morpheus/request_queue.rb', line 19 def queue @queue ||= [] end |
.run! ⇒ Object
31 32 33 34 35 |
# File 'lib/morpheus/request_queue.rb', line 31 def run! uncached_queue.each { |request| hydra.queue(request) } hydra.run queue.clear end |
.uncached_queue ⇒ Object
23 24 25 |
# File 'lib/morpheus/request_queue.rb', line 23 def uncached_queue queue.collect { |request| request if RequestCache.cache[request.cache_key].nil? }.compact end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 |
# File 'lib/morpheus/request_queue.rb', line 8 def call(env) self.class.queue.clear @app.call(env) end |