Module: HTTPX::Plugins::Auth::RequestMethods

Defined in:
lib/httpx/plugins/auth.rb,
sig/plugins/auth.rbs

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#auth_token_value ⇒ String? (readonly)

Returns the value of attribute auth_token_value.

Returns:

  • (String, nil)


151
152
153
# File 'lib/httpx/plugins/auth.rb', line 151

def auth_token_value
  @auth_token_value
end

Instance Method Details

#authorize(auth_value) ⇒ void

This method returns an undefined value.

Parameters:

  • auth_value (String)


170
171
172
173
174
175
176
177
178
179
# File 'lib/httpx/plugins/auth.rb', line 170

def authorize(auth_value)
  @auth_header_value = auth_value
  if (auth_type = @options.auth_header_type)
    @auth_header_value = "#{auth_type} #{@auth_header_value}"
  end

  @headers.add("authorization", @auth_header_value)

  @auth_token_value = auth_value
end

#authorized? ⇒ Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/httpx/plugins/auth.rb', line 158

def authorized?
  !@auth_token_value.nil?
end

#initialize ⇒ Object



153
154
155
156
# File 'lib/httpx/plugins/auth.rb', line 153

def initialize(*)
  super
  @auth_token_value = @auth_header_value = nil
end

#unauthorize! ⇒ void

This method returns an undefined value.



162
163
164
165
166
167
168
# File 'lib/httpx/plugins/auth.rb', line 162

def unauthorize!
  return unless (auth_value = @auth_header_value)

  @headers.get("authorization").delete(auth_value)

  @auth_token_value = @auth_header_value = nil
end