Class: HTTPAuth::Digest::AbstractHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/httpauth/digest.rb

Overview

Superclass for all the header container classes

Direct Known Subclasses

AuthenticationInfo, Challenge, Credentials

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a) ⇒ Object

Redirects attribute messages to the internal directives

Example:

class Credentials < AbstractHeader
  def initialize
    @h = { :username => 'Ben' }
  end
end

c = Credentials.new
c.username #=> 'Ben'
c.username = 'Mary'
c.username #=> 'Mary'


266
267
268
269
270
271
272
273
274
# File 'lib/httpauth/digest.rb', line 266

def method_missing(m, *a)
  if ((m.to_s =~ /^(.*)=$/) == 0) && @h.keys.include?(Regexp.last_match[1].intern)
    @h[Regexp.last_match[1].intern] = a[0]
  elsif @h.keys.include? m
    @h[m]
  else
    fail(NameError, "undefined method `#{m}' for #{self}")
  end
end

Instance Attribute Details

#hObject (readonly)

holds directives and values for digest calculation



250
251
252
# File 'lib/httpauth/digest.rb', line 250

def h
  @h
end