Module: Authlogic::ActsAsAuthentic::LoggedInStatus::Methods

Defined in:
lib/authlogic/acts_as_authentic/logged_in_status.rb

Overview

All methods for the logged in status feature seat.

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/authlogic/acts_as_authentic/logged_in_status.rb', line 29

def self.included(klass)
  return if !klass.column_names.include?("last_request_at")
  
  klass.class_eval do
    include InstanceMethods
    
    if ActiveRecord::VERSION::MAJOR < 3
      named_scope :logged_in, lambda { {:conditions => ["last_request_at > ?", logged_in_timeout.seconds.ago]} }
      named_scope :logged_out, lambda { {:conditions => ["last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago]} }
    else
      scope :logged_in, lambda { {:conditions => ["last_request_at > ?", logged_in_timeout.seconds.ago]} }
      scope :logged_out, lambda { {:conditions => ["last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago]} }
    end
  end
end