Class: Apipie::Extractor::Recorder::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/apipie/extractor/recorder.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



153
154
155
# File 'lib/apipie/extractor/recorder.rb', line 153

def initialize(app)
  @app = app
end

Instance Method Details

#analyze(env, &block) ⇒ Object



167
168
169
170
171
172
173
174
175
# File 'lib/apipie/extractor/recorder.rb', line 167

def analyze(env, &block)
  Apipie::Extractor.call_recorder.analyse_env(env)
  response = block.call
  Apipie::Extractor.call_recorder.analyse_response(response)
  Apipie::Extractor.call_finished
  response
ensure
  Apipie::Extractor.clean_call_recorder
end

#call(env) ⇒ Object



157
158
159
160
161
162
163
164
165
# File 'lib/apipie/extractor/recorder.rb', line 157

def call(env)
  if Apipie.configuration.record
    analyze(env) do
      @app.call(env)
    end
  else
    @app.call(env)
  end
end