Class: Wayfarer::Middleware::UserAgent

Inherits:
Object
  • Object
show all
Extended by:
Base
Defined in:
lib/wayfarer/middleware/user_agent.rb

Defined Under Namespace

Modules: API

Constant Summary

Constants included from Base

Base::API_MODULE

Instance Method Summary collapse

Methods included from Base

api, lazy

Instance Method Details

#call(task) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/wayfarer/middleware/user_agent.rb', line 24

def call(task)
  pool.with do |context|
    task[:context] = context

    result = task[:controller].run_callbacks(:fetch) do
      context.fetch(task.url)
    end

    case result
    when Networking::Result::Redirect
      task[:controller].stage(result.redirect_url)
    when Networking::Result::Success
      task[:page] = result.page
      yield if block_given?
    end
  end
end