Module: ProjectlockerErrata::Rails

Defined in:
lib/projectlocker_errata/rails.rb,
lib/projectlocker_errata/rails/error_lookup.rb,
lib/projectlocker_errata/rails/controller_methods.rb,
lib/projectlocker_errata/rails/javascript_notifier.rb,
lib/projectlocker_errata/rails/action_controller_catcher.rb,
lib/projectlocker_errata/rails/middleware/exceptions_catcher.rb

Defined Under Namespace

Modules: ActionControllerCatcher, ControllerMethods, ErrorLookup, JavascriptNotifier, Middleware

Class Method Summary collapse

Class Method Details

.initializeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/projectlocker_errata/rails.rb', line 9

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