Class: LearnLab::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/learn_lab/token.rb

Overview

Encodable token. Consists of an email, GitHub URL, and timestamp encoded as a Base64 URL safe string.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, url, timestamp = Time.now.utc) ⇒ Token

Returns a new instance of Token.

[View source]

10
11
12
13
14
# File 'lib/learn_lab/token.rb', line 10

def initialize(email, url, timestamp=Time.now.utc)
  @email = email
  @url = url
  @timestamp = timestamp
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.


8
9
10
# File 'lib/learn_lab/token.rb', line 8

def email
  @email
end

#timestampObject (readonly)

Returns the value of attribute timestamp.


8
9
10
# File 'lib/learn_lab/token.rb', line 8

def timestamp
  @timestamp
end

#urlObject (readonly)

Returns the value of attribute url.


8
9
10
# File 'lib/learn_lab/token.rb', line 8

def url
  @url
end

Instance Method Details

#encodedObject

[View source]

16
17
18
# File 'lib/learn_lab/token.rb', line 16

def encoded
  Base64.urlsafe_encode64(payload.to_json)
end