Class: Xenon::Headers::Challenge

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/xenon/headers/www_authenticate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth_scheme, params = {}) ⇒ Challenge

Returns a new instance of Challenge.



16
17
18
19
# File 'lib/xenon/headers/www_authenticate.rb', line 16

def initialize(auth_scheme, params = {})
  @auth_scheme = auth_scheme
  @params = params.with_indifferent_access
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



21
22
23
24
# File 'lib/xenon/headers/www_authenticate.rb', line 21

def method_missing(name, *args, &block)
  name = name.to_sym
  @params.key?(name) ? @params[name] : super
end

Instance Attribute Details

#auth_schemeObject (readonly)

Returns the value of attribute auth_scheme.



13
14
15
# File 'lib/xenon/headers/www_authenticate.rb', line 13

def auth_scheme
  @auth_scheme
end

Instance Method Details

#respond_to_missing?(name, include_all) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/xenon/headers/www_authenticate.rb', line 26

def respond_to_missing?(name, include_all)
  @params.key?(name.to_sym) || super
end

#to_sObject



30
31
32
33
# File 'lib/xenon/headers/www_authenticate.rb', line 30

def to_s
  param_string = @params.map { |k, v| "#{k}=#{v.quote}"}.join(', ')
  "#{@auth_scheme} #{param_string}"
end