Class: Useless::Doc::Proxy::UI

Inherits:
Object
  • Object
show all
Defined in:
lib/useless/doc/proxy/ui.rb

Overview

Doc::Proxy::UI chooses which UI should be used to render the documentation and sets it to ‘useless.doc.ui’.

It could theoretically be chosen via the ‘ui’ parameter, but until there are other UIs, it will alway choose UI::Godel.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ UI

Returns a new instance of UI.



15
16
17
# File 'lib/useless/doc/proxy/ui.rb', line 15

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/useless/doc/proxy/ui.rb', line 19

def call(env)
  request = ::Rack::Request.new(env)

  env['useless.doc.ui'] = case request.params['ui']
    when 'godel'; Useless::Doc::UI::Godel.new(env['useless.doc.router'])
    else          Useless::Doc::UI::Godel.new(env['useless.doc.router'])
  end

  if env['useless.doc.logger']
    env['useless.doc.logger'].debug "selected UI: #{env['useless.doc.ui'].class.name}"
  end

  @app.call(env)
end