Class: SecurityToken

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

Class Method Summary collapse

Class Method Details

.err_msg(msg, token) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/models/token.rb', line 6

def self.err_msg(msg, token)
  hex = ''
  hex = "hex: #{str_hex(token)}\n" if token.instance_of?(String)
  "Invalid token! Token should be a human readable hex string!\n" \
    "  Good sample token: aabbccdd\n" \
    "  #{msg}\n" \
    "  token: #{token}:#{token.class}\n" \
    "  #{hex}"
end

.validate(token) ⇒ Object



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

def self.validate(token)
  raise err_msg("Expected type: String got: #{token.class}", token) unless token.instance_of?(String)
  raise err_msg("Expected size: 8 got: #{token.size}", token) unless token.size == 8
end