Module: SessionLogger::SessionLogging::ClassMethods

Defined in:
lib/session_logger/session_logging.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#enable_session_logging(options = {}) ⇒ Object

Options are the same as the ones for around filter. See docs for around filter



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/session_logger/session_logging.rb', line 9

def enable_session_logging(options={})

  raise "Session Logging can't occur without specifying logged_models in initializers" if SessionLogger.logged_models.blank?

  SessionLogger::SessionObserver.observe(SessionLogger.logged_models)

  if !ActiveRecord::Base.observers.include? SessionLogger::SessionObserver
    ActiveRecord::Base.observers << SessionLogger::SessionObserver if defined?(ActiveRecord) and defined?(ActiveRecord::Base)
  end

  sweeper_instance = SessionLogger::SessionObserver.instance

  around_filter(sweeper_instance, options)
end