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.



126
127
128
# File 'lib/apipie/extractor/recorder.rb', line 126

def initialize(app)
  @app = app
end

Instance Method Details

#analyze(env, &block) ⇒ Object



140
141
142
143
144
145
146
147
148
# File 'lib/apipie/extractor/recorder.rb', line 140

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



130
131
132
133
134
135
136
137
138
# File 'lib/apipie/extractor/recorder.rb', line 130

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