Class: Watchdocs::Rails::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/watchdocs/rails/middleware.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.

[View source]

6
7
8
9
# File 'lib/watchdocs/rails/middleware.rb', line 6

def initialize(app)
  @app = app
  @report = {}
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.


4
5
6
# File 'lib/watchdocs/rails/middleware.rb', line 4

def app
  @app
end

#reportObject (readonly)

Returns the value of attribute report.


4
5
6
# File 'lib/watchdocs/rails/middleware.rb', line 4

def report
  @report
end

Instance Method Details

#call(env) ⇒ Object

[View source]

11
12
13
14
15
16
17
18
19
20
21
# File 'lib/watchdocs/rails/middleware.rb', line 11

def call(env)
  app.call(env).tap do |response|
    if json_response?(response)
      clear_report
      catch_request(env)
      catch_response(response)
      match_endpoint_pattern
      record_call
    end
  end
end