class Airbrake::Rails::Railties::MiddlewareTie

@since v13.0.1
@api private
DebugExceptions, so we don’t notify Airbrake about local requests.
the request is local. We want to insert our middleware after
responsible for logging exceptions and showing a debugging page in case
Since Rails 3.2 the ActionDispatch::DebugExceptions middleware is
Ties Airbrake Rails Middleware with Rails (error sending).

def call

def call
  return tie_rails_5_or_above if ::Rails.version.to_i >= 5
  if defined?(::ActiveRecord::ConnectionAdapters::ConnectionManagement)
    return tie_rails_4_or_below_with_active_record
  end
  tie_rails_4_or_below_without_active_record
end

def initialize(app)

def initialize(app)
  @app = app
  @middleware = app.config.middleware
end

def tie_rails_4_or_below_with_active_record

https://github.com/airbrake/airbrake/pull/568
Insert after ConnectionManagement to avoid DB connection leakage:
def tie_rails_4_or_below_with_active_record
  @middleware.insert_after(
    ::ActiveRecord::ConnectionAdapters::ConnectionManagement,
    'Airbrake::Rack::Middleware',
  )
end

def tie_rails_4_or_below_without_active_record

Insert after DebugExceptions for apps without ActiveRecord.
def tie_rails_4_or_below_without_active_record
  @middleware.insert_after(
    ActionDispatch::DebugExceptions,
    'Airbrake::Rack::Middleware',
  )
end

def tie_rails_5_or_above

exist in Rails 5 anymore.
Insert after DebugExceptions, since ConnectionManagement doesn't
Avoid the warning about deprecated strings.
def tie_rails_5_or_above
  @middleware.insert_after(
    ActionDispatch::DebugExceptions,
    Airbrake::Rack::Middleware,
  )
end