Sha256: 59b62c41494330a25c875e0d6994f0e5bc6ed975a49f74b016ec9c15a6919ac4

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

require 'sqreen/middleware'
require 'sqreen/error_handling_middleware'
require 'sqreen/rails_middleware'

module Sqreen
  module Dependency
    module Rails
      module_function

      def required?
        Sqreen::Dependency.const_exist?('Rails::Application')
      end

      def server?
        Sqreen::Dependency.const_exist?('Rails::Server') && ObjectSpace.each_object(::Rails::Server).count > 0
      end

      def inspect_middlewares
        return unless ::Rails.application.middleware.respond_to?(:map)

        Sqreen.log.debug { "Middlewares: " << ::Rails.application.middleware.map(&:inspect).inspect }
      end

      def insert_sqreen_middlewares
        Sqreen.log.debug { 'Inserting Sqreen middlewares for Rails' }
        app = ::Rails.application
        app.middleware.insert_after(::Rack::Runtime, Sqreen::Middleware)
        app.middleware.insert_after(::ActionDispatch::DebugExceptions, Sqreen::RailsMiddleware)
        app.middleware.insert_after(::ActionDispatch::DebugExceptions, Sqreen::ErrorHandlingMiddleware)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sqreen-1.18.6-java lib/sqreen/dependency/rails.rb
sqreen-1.18.6 lib/sqreen/dependency/rails.rb
sqreen-1.18.5-java lib/sqreen/dependency/rails.rb
sqreen-1.18.5 lib/sqreen/dependency/rails.rb
sqreen-1.18.4-java lib/sqreen/dependency/rails.rb
sqreen-1.18.4 lib/sqreen/dependency/rails.rb
sqreen-1.18.3-java lib/sqreen/dependency/rails.rb
sqreen-1.18.3 lib/sqreen/dependency/rails.rb
sqreen-1.18.3.beta2 lib/sqreen/dependency/rails.rb