Class: Drillbit::Tokens::Base64

Inherits:
Object
  • Object
show all
Defined in:
lib/drillbit/tokens/base64.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:) ⇒ Base64

Returns a new instance of Base64.



11
12
13
# File 'lib/drillbit/tokens/base64.rb', line 11

def initialize(token:)
  self.token = token
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



9
10
11
# File 'lib/drillbit/tokens/base64.rb', line 9

def token
  @token
end

Class Method Details

.convert(raw_token:) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/drillbit/tokens/base64.rb', line 34

def self.convert(raw_token:)
  return Base64s::Null.instance if raw_token.to_s == ''

  ::Base64.strict_decode64(raw_token)

  new(token: raw_token)
rescue ArgumentError
  Base64s::Invalid.instance
end

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/drillbit/tokens/base64.rb', line 19

def blank?
  false
end

#to_hObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/drillbit/tokens/base64.rb', line 23

def to_h
  [
    {
      'token' => token,
    },
    {
      'typ' => 'base64',
    },
  ]
end

#valid?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/drillbit/tokens/base64.rb', line 15

def valid?
  true
end