Module: Sorcery::Model::Submodules::ActivityLogging
- Defined in:
- lib/sorcery/model/submodules/activity_logging.rb
Overview
This submodule keeps track of events such as login, logout, and last activity time, per user. It helps in estimating which users are active now in the site. This cannot be determined absolutely because a user might be reading a page without clicking anything for a while. This is the model part of the submodule, which provides configuration options.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sorcery/model/submodules/activity_logging.rb', line 10 def self.included(base) base.extend(ClassMethods) base.sorcery_config.class_eval do attr_accessor :last_login_at_attribute_name, # last login attribute name. :last_logout_at_attribute_name, # last logout attribute name. :last_activity_at_attribute_name, # last activity attribute name. :activity_timeout # how long since last activity is #the user defined logged out? end base.sorcery_config.instance_eval do @defaults.merge!(:@last_login_at_attribute_name => :last_login_at, :@last_logout_at_attribute_name => :last_logout_at, :@last_activity_at_attribute_name => :last_activity_at, :@activity_timeout => 10 * 60) reset! end base.sorcery_config.after_config << :define_activity_logging_mongoid_fields if defined?(Mongoid) and base.ancestors.include?(Mongoid::Document) end |