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_valueString? (readonly)

Returns the value of attribute auth_token_value.

Returns:

  • (String, nil)


146
147
148
# File 'lib/httpx/plugins/auth.rb', line 146

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)


165
166
167
168
169
170
171
172
173
174
# File 'lib/httpx/plugins/auth.rb', line 165

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)


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

def authorized?
  !@auth_token_value.nil?
end

#initializeObject



148
149
150
151
# File 'lib/httpx/plugins/auth.rb', line 148

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

#unauthorize!void

This method returns an undefined value.



157
158
159
160
161
162
163
# File 'lib/httpx/plugins/auth.rb', line 157

def unauthorize!
  return unless (auth_value = @auth_header_value)

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

  @auth_token_value = @auth_header_value = nil
end