Sha256: e86d4a83d8a4150e77b287389722f8a7d022a08fcd0366bc56030c0f8b1bedbe

Contents?: true

Size: 1.9 KB

Versions: 4

Compression:

Stored size: 1.9 KB

Contents

require 'projectlocker_errata'
require 'projectlocker_errata/rails/controller_methods'
require 'projectlocker_errata/rails/action_controller_catcher'
require 'projectlocker_errata/rails/error_lookup'
require 'projectlocker_errata/rails/javascript_notifier'

module ProjectlockerErrata
  module Rails
    def self.initialize
      if defined?(ActionController::Base)
        ActionController::Base.send(:include, ProjectlockerErrata::Rails::ActionControllerCatcher)
        ActionController::Base.send(:include, ProjectlockerErrata::Rails::ErrorLookup)
        ActionController::Base.send(:include, ProjectlockerErrata::Rails::ControllerMethods)
        ActionController::Base.send(:include, ProjectlockerErrata::Rails::JavascriptNotifier)
      end

      rails_logger = if defined?(::Rails.logger)
                       ::Rails.logger
                     elsif defined?(RAILS_DEFAULT_LOGGER)
                       RAILS_DEFAULT_LOGGER
                     end

      if defined?(::Rails.configuration) && ::Rails.configuration.respond_to?(:middleware)
        ::Rails.configuration.middleware.insert_after 'ActionController::Failsafe',
                                                      ProjectlockerErrata::Rack
        ::Rails.configuration.middleware.insert_after 'Rack::Lock',
                                                      ProjectlockerErrata::UserInformer
      end

      ProjectlockerErrata.configure(true) do |config|
        config.logger           = rails_logger
        config.environment_name = defined?(::Rails.env) && ::Rails.env || defined?(RAILS_ENV) && RAILS_ENV
        config.project_root     = defined?(::Rails.root) && ::Rails.root || defined?(RAILS_ROOT) && RAILS_ROOT
        config.framework        = defined?(::Rails.version) && "Rails: #{::Rails.version}" || defined?(::Rails::VERSION::STRING) && "Rails: #{::Rails::VERSION::STRING}"
      end
    end
  end
end

ProjectlockerErrata::Rails.initialize

Version data entries

4 entries across 4 versions & 1 rubygems

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