Class: AuthBearer

Inherits:
Object
  • Object
show all
Includes:
AuthProvider
Defined in:
lib/sideko_hacker_news.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val: nil) ⇒ AuthBearer

Returns a new instance of AuthBearer.



53
54
55
# File 'lib/sideko_hacker_news.rb', line 53

def initialize(val: nil)
  @val = val
end

Instance Attribute Details

#valObject

Returns the value of attribute val.



51
52
53
# File 'lib/sideko_hacker_news.rb', line 51

def val
  @val
end

Instance Method Details

#add_auth(http_client, req_kwargs) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/sideko_hacker_news.rb', line 57

def add_auth(http_client, req_kwargs)
  if !@val.nil?
    headers = req_kwargs.fetch(:headers, {})
    headers["Authorization"] = "Bearer " + @val
    req_kwargs[:headers] = headers
  end

  return http_client, req_kwargs
end