Class: OpenID::BaseAssociationManager
- Inherits:
-
AssociationManager
- Object
- AssociationManager
- OpenID::BaseAssociationManager
- Defined in:
- lib/openid/association.rb
Overview
class DumbAssociationManager
Instance Method Summary collapse
-
#associate(server_url) ⇒ Object
Returns assoc_handle associated with server_url.
-
#get_all(server_url) ⇒ Object
This must be implemented by subclasses.
- #get_association(server_url, assoc_handle) ⇒ Object
-
#initialize(associator) ⇒ BaseAssociationManager
constructor
A new instance of BaseAssociationManager.
-
#invalidate(server_url, assoc_handle) ⇒ Object
This must be implemented by subclasses.
-
#update(new_assoc, expired) ⇒ Object
This must be implemented by subclasses.
Constructor Details
#initialize(associator) ⇒ BaseAssociationManager
Returns a new instance of BaseAssociationManager.
81 82 83 |
# File 'lib/openid/association.rb', line 81 def initialize(associator) @associator = associator end |
Instance Method Details
#associate(server_url) ⇒ Object
Returns assoc_handle associated with server_url
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/openid/association.rb', line 85 def associate(server_url) now = Time.now expired = [] assoc = nil get_all(server_url).each { |current| replace_after = current.get_replace_after if current.expiry < now expired.push(current) elsif assoc == nil assoc = current if replace_after > now elsif replace_after > assoc.replace_after assoc = current end } new_assoc = nil if assoc == nil assoc = new_assoc = @associator.associate(server_url) end if new_assoc or expired update(new_assoc, expired) end return assoc.handle end |
#get_all(server_url) ⇒ Object
This must be implemented by subclasses.
Should return a list of Association objects matching server_url
130 131 132 |
# File 'lib/openid/association.rb', line 130 def get_all(server_url) raise NotImplementedError end |
#get_association(server_url, assoc_handle) ⇒ Object
110 111 112 113 114 115 |
# File 'lib/openid/association.rb', line 110 def get_association(server_url, assoc_handle) get_all(server_url).each { |assoc| return assoc if assoc.handle == assoc_handle } return nil end |
#invalidate(server_url, assoc_handle) ⇒ Object
This must be implemented by subclasses.
Subclass should remove the association for the given server_url and assoc_handle.
138 139 140 |
# File 'lib/openid/association.rb', line 138 def invalidate(server_url, assoc_handle) raise NotImplementedError end |
#update(new_assoc, expired) ⇒ Object
This must be implemented by subclasses.
new_assoc is either a new association object or nil. Expired is a possibly empty list of expired associations. Subclass should add new_assoc if it is not nil, and expire each association in the expired list.
123 124 125 |
# File 'lib/openid/association.rb', line 123 def update(new_assoc, expired) raise NotImplementedError end |