Class: Etwin::Client::Auth

Inherits:
Object
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/etwin/client/auth.rb

Overview

Eternal-Twin client authentication data

Constant Summary collapse

Guest =
T.let(new(nil), Auth)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorization_header) ⇒ Auth

Returns a new instance of Auth.



17
18
19
20
# File 'lib/etwin/client/auth.rb', line 17

def initialize(authorization_header)
  @authorization_header = T.let(authorization_header, T.nilable(String))
  freeze
end

Instance Attribute Details

#authorization_headerObject (readonly)

Returns the value of attribute authorization_header.



14
15
16
# File 'lib/etwin/client/auth.rb', line 14

def authorization_header
  @authorization_header
end

Class Method Details

.from_token(key) ⇒ Object



60
61
62
# File 'lib/etwin/client/auth.rb', line 60

def from_token(key)
  new("Bearer #{key}")
end

Instance Method Details

#==(other) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/etwin/client/auth.rb', line 23

def ==(other)
  case other
  when Auth
    @authorization_header == other.authorization_header
  else
    false
  end
end

#hashObject



33
34
35
# File 'lib/etwin/client/auth.rb', line 33

def hash
  [@authorization_header].hash
end

#inspectObject



38
39
40
# File 'lib/etwin/client/auth.rb', line 38

def inspect
  PP.singleline_pp(self, String.new)
end

#pretty_print(pp) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/etwin/client/auth.rb', line 43

def pretty_print(pp)
  pp.group(0, "#{self.class.name}(", ')') do
    pp.nest 1 do
      pp.breakable ''
      pp.text 'authorization_header='
      pp.pp @authorization_header
    end
    pp.breakable ''
  end
end