Class: OpenID::Extension

Inherits:
Object
  • Object
show all
Defined in:
lib/openid/extension.rb

Overview

An interface for OpenID extensions.

Instance Method Summary collapse

Constructor Details

#initializeExtension

Returns a new instance of Extension.



7
8
9
10
# File 'lib/openid/extension.rb', line 7

def initialize
  @ns_uri = nil
  @ns_alias = nil
end

Instance Method Details

#get_extension_argsObject

Get the string arguments that should be added to an OpenID message for this extension.

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/openid/extension.rb', line 14

def get_extension_args
  raise NotImplementedError
end

#to_message(message = nil) ⇒ Object

Add the arguments from this extension to the provided message, or create a new message containing only those arguments. Returns the message with added extension args.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/openid/extension.rb', line 21

def to_message(message = nil)
  if message.nil?
#         warnings.warn('Passing None to Extension.toMessage is deprecated. '
#                       'Creating a message assuming you want OpenID 2.',
#                       DeprecationWarning, stacklevel=2)
    Message.new(OPENID2_NS)
  end
  message = Message.new if message.nil?

  implicit = message.is_openid1()

  message.namespaces.add_alias(@ns_uri, @ns_alias, implicit)
  # XXX python ignores keyerror if m.ns.getAlias(uri) == alias

  message.update_args(@ns_uri, get_extension_args)
  return message
end