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.



122
123
124
# File 'lib/apipie/extractor/recorder.rb', line 122

def initialize(app)
  @app = app
end

Instance Method Details

#analyze(env, &block) ⇒ Object



136
137
138
139
140
141
142
143
144
# File 'lib/apipie/extractor/recorder.rb', line 136

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



126
127
128
129
130
131
132
133
134
# File 'lib/apipie/extractor/recorder.rb', line 126

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