Sha256: 9d89d7de835da0e128227866b079c34d82a7845ed1a92bb3dacae1db1febec98

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

module EffectiveLogging
  class Engine < ::Rails::Engine
    engine_name 'effective_logging'

    # Set up our default configuration options.
    initializer "effective_logging.defaults", :before => :load_config_initializers do |app|
      eval File.read("#{config.root}/lib/generators/templates/effective_logging.rb")
    end

    # ActiveAdmin (optional)
    # This prepends the load path so someone can override the assets.rb if they want.
    initializer 'effective_logging.active_admin' do
      if defined?(ActiveAdmin) && EffectiveLogging.use_active_admin == true
        ActiveAdmin.application.load_paths.unshift Dir["#{config.root}/active_admin"]
      end
    end

    # Automatically Log Emails
    initializer 'effective_logging.emails' do |app|
      if EffectiveLogging.emails_enabled == true
        require 'effective_logging/email_logger'
        ActionMailer::Base.register_interceptor(EffectiveLogging::EmailLogger)
      end
    end

    # Register the log_page_views concern so that it can be called in ActionController or elsewhere
    initializer 'effective_logging.action_controller' do |app|
      ActiveSupport.on_load :action_controller do
        ActionController::Base.extend(EffectiveLogging::LogPageViews::ActionController)
      end
    end

    # This has to be run after initialization or User hasn't been loaded yet
    config.after_initialize do
      if EffectiveLogging.user_logins_enabled == true
        ActiveSupport.on_load :active_record do
          if defined?(Devise)
            EffectiveLogging::UserLogger.create_warden_hooks()
          else
            raise ArgumentError.new("EffectiveLogging.user_logins_enabled only works with Devise")
          end
        end
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
effective_logging-1.4.1 lib/effective_logging/engine.rb
effective_logging-1.4.0 lib/effective_logging/engine.rb