Class: OpenCoinage::XMLRPC::Server

Inherits:
XMLRPC::BasicServer
  • Object
show all
Defined in:
lib/opencoinage/xmlrpc/server.rb

Overview

An OpenCoinage XML-RPC server implementation.

See Also:

Instance Method Summary (collapse)

Constructor Details

- (Server) initialize(options = {})

Initializes the XML-RPC server.

Parameters:

  • (Hash{Symbol => Object}) options (defaults to: {})

Options Hash (options):

  • (Boolean) :multicall — default: true
  • (Boolean) :introspection — default: true
  • (Boolean) :capabilities — default: true


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/opencoinage/xmlrpc/server.rb', line 23

def initialize(options = {})
  @options = options.dup
  super()
  add_multicall     unless @options[:multicall]     == false
  add_introspection unless @options[:introspection] == false
  add_capabilities  unless @options[:capabilities]  == false
  add_handler('opencoinage.version',  %w(string),         '', &method(:version))
  add_handler('opencoinage.verify',   %w(boolean string), '', &method(:verify))
  add_handler('opencoinage.describe', %w(struct string),  '', &method(:describe))
  add_handler('opencoinage.reissue',  %w(string string),  '', &method(:reissue))
end

Instance Method Details

- add_capabilities(options = {}) (protected)

This method returns an undefined value.

Implements the system.getCapabilities standard method, enabling clients to determine whether a given capability is supported by this server.

Parameters:

  • (Hash{Symbol => Object}) options (defaults to: {})

Options Hash (options):

  • (Boolean) :faults_interop — default: true

    whether to indicate support for the XMLRPC-EPI Specification for Fault Code Interoperability

See Also:



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/opencoinage/xmlrpc/server.rb', line 92

def add_capabilities(options = {})
  add_handler('system.getCapabilities', %w(struct), '') do
    capabilities = {}
    unless options[:faults_interop] == false
      capabilities['faults_interop'] = {
        'specUrl'     => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
        'specVersion' => 20010516,
      }
    end
    capabilities
  end
  self
end

- (Hash) describe(token)

Returns information about the given token.

Parameters:

  • (String) token

    the token to describe (encoded as a Base62 string)

Returns:

  • (Hash)

    a key-value mapping describing the token

Raises:

  • (NotImplementedError)

See Also:



62
63
64
# File 'lib/opencoinage/xmlrpc/server.rb', line 62

def describe(token)
  raise NotImplementedError, "#{self.class}#describe"
end

- (String) reissue(token, identifier = nil)

Issues a new token equivalent to the given token.

Parameters:

  • (String) token

    the valid token to reissue (encoded as a Base62 string)

  • (String) identifier (defaults to: nil)

    a unique identifier for the new token (encoded as a Base62 string)

Returns:

  • (String)

    a new token (encoded as a Base62 string)

Raises:

  • (NotImplementedError)

See Also:



75
76
77
# File 'lib/opencoinage/xmlrpc/server.rb', line 75

def reissue(token, identifier = nil)
  raise NotImplementedError, "#{self.class}#reissue"
end

- (Boolean) verify(token)

Returns true if the given token is valid, false otherwise.

Parameters:

  • (String) the

    token to verify (encoded as a Base62 string)

Returns:

  • (Boolean)

    true or false

Raises:

  • (NotImplementedError)

See Also:



51
52
53
# File 'lib/opencoinage/xmlrpc/server.rb', line 51

def verify(token)
  raise NotImplementedError, "#{self.class}#verify"
end

- (String) version

Returns the server's version number.

Returns:

  • (String)

    an "x.y.z" version number string

See Also:



40
41
42
# File 'lib/opencoinage/xmlrpc/server.rb', line 40

def version
  OpenCoinage::VERSION.to_s
end