Class: Authlogic::CookieCredentials Private

Inherits:
Object
  • Object
show all
Defined in:
lib/authlogic/cookie_credentials.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Represents the credentials in the cookie. The value of the cookie. This is primarily a data object. It doesn’t interact with controllers. It doesn’t know about eg. cookie expiration.

Defined Under Namespace

Classes: ParseError

Constant Summary collapse

DELIMITER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

"::"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(persistence_token, record_id, remember_me_until) ⇒ CookieCredentials

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CookieCredentials.

Parameters:

  • persistence_token (String)
  • record_id (String, Numeric)
  • remember_me_until (ActiveSupport::TimeWithZone)


22
23
24
25
26
# File 'lib/authlogic/cookie_credentials.rb', line 22

def initialize(persistence_token, record_id, remember_me_until)
  @persistence_token = persistence_token
  @record_id = record_id
  @remember_me_until = remember_me_until
end

Instance Attribute Details

#persistence_tokenObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/authlogic/cookie_credentials.rb', line 16

def persistence_token
  @persistence_token
end

#record_idObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/authlogic/cookie_credentials.rb', line 16

def record_id
  @record_id
end

#remember_me_untilObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/authlogic/cookie_credentials.rb', line 16

def remember_me_until
  @remember_me_until
end

Class Method Details

.parse(string) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
36
# File 'lib/authlogic/cookie_credentials.rb', line 30

def parse(string)
  parts = string.split(DELIMITER)
  unless (1..3).cover?(parts.length)
    raise ParseError, format("Expected 1..3 parts, got %d", parts.length)
  end
  new(parts[0], parts[1], parse_time(parts[2]))
end

Instance Method Details

#remember_me?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


50
51
52
# File 'lib/authlogic/cookie_credentials.rb', line 50

def remember_me?
  !@remember_me_until.nil?
end

#to_sObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



55
56
57
58
59
60
61
# File 'lib/authlogic/cookie_credentials.rb', line 55

def to_s
  [
    @persistence_token,
    @record_id.to_s,
    @remember_me_until&.iso8601
  ].compact.join(DELIMITER)
end