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.



87
88
89
# File 'lib/apipie/extractor/recorder.rb', line 87

def initialize(app)
  @app = app
end

Instance Method Details

#analyze(env, &block) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/apipie/extractor/recorder.rb', line 101

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



91
92
93
94
95
96
97
98
99
# File 'lib/apipie/extractor/recorder.rb', line 91

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