Sha256: 6f2db85f87d0493e7c5a6860df14e2f68212e2769fc62738a5d2013dcf98ca8b

Contents?: true

Size: 1.94 KB

Versions: 4

Compression:

Stored size: 1.94 KB

Contents

require 'projectlocker_errata'
require 'rails'

module ProjectlockerErrata
  class Railtie < ::Rails::Railtie
    rake_tasks do
      require 'projectlocker_errata/rake_handler'
      require "projectlocker_errata/rails3_tasks"
    end

    initializer "projectlocker_errata.use_rack_middleware" do |app|
      app.config.middleware.insert 0, "ProjectlockerErrata::UserInformer"
      app.config.middleware.insert_after "ProjectlockerErrata::UserInformer","ProjectlockerErrata::Rack"
    end

    config.after_initialize do
      ProjectlockerErrata.configure(true) do |config|
        config.logger           ||= config.async? ? ::Logger.new(STDERR) : ::Rails.logger
        config.environment_name ||= ::Rails.env
        config.project_root     ||= ::Rails.root
        config.framework        = "Rails: #{::Rails::VERSION::STRING}"
      end

      ActiveSupport.on_load(:action_controller) do
        # Lazily load action_controller methods
        #
        require 'projectlocker_errata/rails/javascript_notifier'
        require 'projectlocker_errata/rails/controller_methods'

        include ProjectlockerErrata::Rails::JavascriptNotifier
        include ProjectlockerErrata::Rails::ControllerMethods
      end

      if defined?(::ActionDispatch::DebugExceptions)
        # We should catch the exceptions in ActionDispatch::DebugExceptions in Rails 3.2.x.
        #
        require 'projectlocker_errata/rails/middleware/exceptions_catcher'
        ::ActionDispatch::DebugExceptions.send(:include,ProjectlockerErrata::Rails::Middleware::ExceptionsCatcher)
      elsif defined?(::ActionDispatch::ShowExceptions)
        # ActionDispatch::DebugExceptions is not defined in Rails 3.0.x and 3.1.x so
        # catch the exceptions in ShowExceptions.
        #
        require 'projectlocker_errata/rails/middleware/exceptions_catcher'
        ::ActionDispatch::ShowExceptions.send(:include,ProjectlockerErrata::Rails::Middleware::ExceptionsCatcher)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
projectlocker_errata-0.1.1 lib/projectlocker_errata/railtie.rb
projectlocker_errata-0.1.0 lib/projectlocker_errata/railtie.rb
projectlocker_errata-0.0.2 lib/projectlocker_errata/railtie.rb
projectlocker_errata-0.0.1 lib/projectlocker_errata/railtie.rb