Class: Sinatra::RPC::Serializer::XMLRPC

Inherits:
Base
  • Object
show all
Defined in:
lib/sinatra/rpc/serializer/xmlrpc.rb

Overview

This class handles XML-RPC calls.

Instance Method Summary collapse

Methods inherited from Base

#content_type, content_types

Constructor Details

#initializeXMLRPC

This initializer creates an internal XMLRPC::Marshal instance.


12
13
14
# File 'lib/sinatra/rpc/serializer/xmlrpc.rb', line 12

def initialize
  @xmlrpc = ::XMLRPC::Marshal.new
end

Instance Method Details

#content_type_optionsObject

The charset is set to UTF-8. (see Base#content_type_options)


18
19
20
# File 'lib/sinatra/rpc/serializer/xmlrpc.rb', line 18

def content_type_options
  {charset: 'utf-8'}
end

#dump(response) ⇒ String

Convert the response object to a string to be used in the body of the HTTP response. Must be implemented by subclasses.


28
29
30
31
32
33
# File 'lib/sinatra/rpc/serializer/xmlrpc.rb', line 28

def dump(response)
  if Sinatra::RPC::Fault === response 
    response = ::XMLRPC::FaultException.new(response.code, response.message)
  end
  @xmlrpc.dump_response(response)
end

#parse(request) ⇒ Array

Parse an incoming RPC request. This method must be implemented by subclasses.


23
24
25
# File 'lib/sinatra/rpc/serializer/xmlrpc.rb', line 23

def parse(request)
  @xmlrpc.load_call(request)
end