Class: RorVsWild::Plugin::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/rorvswild/plugin/middleware.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, config) ⇒ Middleware

Returns a new instance of Middleware.


10
11
12
# File 'lib/rorvswild/plugin/middleware.rb', line 10

def initialize(app, config)
  @app, @config = app, config
end

Class Method Details

.setupObject


4
5
6
7
8
# File 'lib/rorvswild/plugin/middleware.rb', line 4

def self.setup
  return if @installed
  Rails.application.config.middleware.unshift(RorVsWild::Plugin::Middleware, nil) if defined?(Rails)
  @installed = true
end

Instance Method Details

#call(env) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rorvswild/plugin/middleware.rb', line 14

def call(env)
  RorVsWild.agent.start_request
  RorVsWild.agent.current_data[:path] = env["ORIGINAL_FULLPATH".freeze]
  section = RorVsWild::Section.start
  section.file, section.line = rails_engine_location
  section.command = "Rails::Engine#call".freeze
  @app.call(env)
ensure
  RorVsWild::Section.stop
  RorVsWild.agent.stop_request
end

#rails_engine_locationObject


26
27
28
# File 'lib/rorvswild/plugin/middleware.rb', line 26

def rails_engine_location
  @rails_engine_location = ::Rails::Engine.instance_method(:call).source_location
end