Class: Shaf::Authenticator::Challenge

Inherits:
Object
  • Object
show all
Defined in:
lib/shaf/authenticator/challenge.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scheme, **parameters, &block) ⇒ Challenge

Returns a new instance of Challenge.



8
9
10
11
12
13
# File 'lib/shaf/authenticator/challenge.rb', line 8

def initialize(scheme, **parameters, &block)
  @scheme = scheme
  @realm = parameters.delete(:realm)&.to_s
  @parameters = parameters
  define_singleton_method(:test, &block)
end

Instance Attribute Details

#parametersObject (readonly)

Returns the value of attribute parameters.



6
7
8
# File 'lib/shaf/authenticator/challenge.rb', line 6

def parameters
  @parameters
end

#realmObject (readonly)

Returns the value of attribute realm.



6
7
8
# File 'lib/shaf/authenticator/challenge.rb', line 6

def realm
  @realm
end

#schemeObject (readonly)

Returns the value of attribute scheme.



6
7
8
# File 'lib/shaf/authenticator/challenge.rb', line 6

def scheme
  @scheme
end

Instance Method Details

#realm?(arg) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/shaf/authenticator/challenge.rb', line 19

def realm?(arg)
  realm&.to_s == arg&.to_s
end

#to_sObject



15
16
17
# File 'lib/shaf/authenticator/challenge.rb', line 15

def to_s
  "#{scheme} #{parameter_string}"
end