Class: Authentication::Logic::CookieCredentials Private

Inherits:
Object
  • Object
show all
Defined in:
lib/auth/logic/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.

API:

  • private

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.

API:

  • private

"::"

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:

API:

  • private



23
24
25
26
27
# File 'lib/auth/logic/cookie_credentials.rb', line 23

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.

API:

  • private



17
18
19
# File 'lib/auth/logic/cookie_credentials.rb', line 17

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.

API:

  • private



17
18
19
# File 'lib/auth/logic/cookie_credentials.rb', line 17

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.

API:

  • private



17
18
19
# File 'lib/auth/logic/cookie_credentials.rb', line 17

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.

Raises:

API:

  • private



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

def parse(string)
  parts = string.split(DELIMITER)
  raise ParseError, format("Expected 1..3 parts, got %d", parts.length) unless (1..3).cover?(parts.length)

  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:

API:

  • private



51
52
53
# File 'lib/auth/logic/cookie_credentials.rb', line 51

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.

API:

  • private



56
57
58
59
60
61
62
# File 'lib/auth/logic/cookie_credentials.rb', line 56

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