Class: Apiphobic::Tokens::Base64
- Inherits:
-
Object
- Object
- Apiphobic::Tokens::Base64
- Defined in:
- lib/apiphobic/tokens/base64.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #blank? ⇒ Boolean
-
#initialize(token:) ⇒ Base64
constructor
A new instance of Base64.
- #to_h ⇒ Object
- #valid? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(token:) ⇒ Base64
Returns a new instance of Base64.
12 13 14 |
# File 'lib/apiphobic/tokens/base64.rb', line 12 def initialize(token:) self.token = token end |
Instance Attribute Details
#token ⇒ Object
Returns the value of attribute token.
10 11 12 |
# File 'lib/apiphobic/tokens/base64.rb', line 10 def token @token end |
Class Method Details
.convert(raw_token:) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/apiphobic/tokens/base64.rb', line 39 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 raise Erratum::Errors::InvalidToken end |
Instance Method Details
#blank? ⇒ Boolean
24 25 26 |
# File 'lib/apiphobic/tokens/base64.rb', line 24 def blank? false end |
#to_h ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/apiphobic/tokens/base64.rb', line 28 def to_h [ { 'token' => token, }, { 'typ' => 'base64', }, ] end |
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/apiphobic/tokens/base64.rb', line 16 def valid? true end |
#validate! ⇒ Object
20 21 22 |
# File 'lib/apiphobic/tokens/base64.rb', line 20 def validate! true end |