Class: Morpheus::RequestQueue

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

Class Method Summary collapse

Instance Method Summary collapse

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

Returns:

  • (Boolean)


37
38
39
# File 'lib/morpheus/request_queue.rb', line 37

def has_request?(request)
  queue.include?(request)
end

.hydraObject



27
28
29
# File 'lib/morpheus/request_queue.rb', line 27

def hydra
  Configuration.hydra
end

.queueObject



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_queueObject



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