Class: AuthKeyHeader

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(header_name: nil, val: nil) ⇒ AuthKeyHeader

Returns a new instance of AuthKeyHeader.



94
95
96
97
# File 'lib/sideko_hacker_news.rb', line 94

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

Instance Attribute Details

#header_nameObject

Returns the value of attribute header_name.



92
93
94
# File 'lib/sideko_hacker_news.rb', line 92

def header_name
  @header_name
end

#valObject

Returns the value of attribute val.



92
93
94
# File 'lib/sideko_hacker_news.rb', line 92

def val
  @val
end

Instance Method Details

#add_auth(http_client, req_kwargs) ⇒ Object



99
100
101
102
103
104
105
106
107
# File 'lib/sideko_hacker_news.rb', line 99

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

  return http_client, req_kwargs
end