Class: Grape::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/grape-async/endpoint.rb

Defined Under Namespace

Classes: DeferrableResp

Instance Method Summary collapse

Instance Method Details

#async_route?(method = nil) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
# File 'lib/grape-async/endpoint.rb', line 16

def async_route?(method = nil)
  async_settings = route_setting(:async) || {}
  async = async_settings.fetch(:async, false)
  async_method = async_settings.fetch(:async_method, :threaded)
  if method
    async && async_method == method.to_sym
  else
    async
  end
end

#deferred_respObject



10
11
12
13
14
# File 'lib/grape-async/endpoint.rb', line 10

def deferred_resp
  if async_route?(:em)
    @deferred_resp ||= DeferrableResp.new
  end
end

#doneObject



27
28
29
30
31
# File 'lib/grape-async/endpoint.rb', line 27

def done
  if deferred_resp.is_a?(DeferrableResp)
    deferred_resp.set_deferred_status :succeeded
  end
end