Class: Toktok::Token

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity: nil, jwt: nil, payload: nil) ⇒ Token

Returns a new instance of Token.



10
11
12
13
14
15
16
17
18
# File 'lib/toktok/token.rb', line 10

def initialize(identity: nil, jwt: nil, payload: nil)
  @config = Toktok.config
  @payload = {}
  if jwt
    initialize_decode(jwt, identity)
  else
    initialize_encode(identity, payload)
  end
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#jwtObject (readonly)

Returns the value of attribute jwt.



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

def jwt
  @jwt
end

#payloadObject (readonly)

Returns the value of attribute payload.



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

def payload
  @payload
end

Instance Method Details

#identityObject



20
21
22
# File 'lib/toktok/token.rb', line 20

def identity
  payload[:sub]
end