Class: Useless::Doc::Rack::Retriever

Inherits:
Object
  • Object
show all
Defined in:
lib/useless/doc/rack/retriever.rb

Overview

Doc::Rack::Retriever sets an appropriate retriever for the current RACK_ENV. In production it uses the Standard retriever which makes real HTTP calls. Elsewhere, it uses Stub which servers corresponding files from the spec/documents directory.

Defined Under Namespace

Modules: Standard Classes: Stub

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Retriever

Returns a new instance of Retriever.



11
12
13
# File 'lib/useless/doc/rack/retriever.rb', line 11

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/useless/doc/rack/retriever.rb', line 15

def call(env)
  if ENV['RACK_ENV'] == 'production'
    env['useless.doc.retriever'] = Standard
  else
    env['useless.doc.retriever'] = Stub
  end

  @app.call(env)
end