Updated RubySpec submodule to 9f66d0b1.
[rbx.git] / stdlib / xmlrpc / marshal.rb
blobba8c720a01170c579029d26b720f97bcacb48d15
2 # Marshalling of XML-RPC methodCall and methodResponse
3
4 # Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
6 # $Id: marshal.rb 11708 2007-02-12 23:01:19Z shyouhei $
9 require "xmlrpc/parser"
10 require "xmlrpc/create"
11 require "xmlrpc/config"
12 require "xmlrpc/utils"
14 module XMLRPC
16   class Marshal
17     include ParserWriterChooseMixin
19     # class methods -------------------------------
20    
21     class << self
23       def dump_call( methodName, *params )
24         new.dump_call( methodName, *params )
25       end
27       def dump_response( param )
28         new.dump_response( param )
29       end
31       def load_call( stringOrReadable )
32         new.load_call( stringOrReadable )
33       end
35       def load_response( stringOrReadable )
36         new.load_response( stringOrReadable )
37       end
39       alias dump dump_response
40       alias load load_response
42     end # class self
44     # instance methods ----------------------------
46     def initialize( parser = nil, writer = nil )
47       set_parser( parser )
48       set_writer( writer )
49     end
51     def dump_call( methodName, *params )
52       create.methodCall( methodName, *params )
53     end
55     def dump_response( param ) 
56       create.methodResponse( ! param.kind_of?( XMLRPC::FaultException ) , param )
57     end
59     ##
60     # returns [ methodname, params ]
61     #
62     def load_call( stringOrReadable )
63       parser.parseMethodCall( stringOrReadable )
64     end
66     ##
67     # returns paramOrFault
68     #
69     def load_response( stringOrReadable )
70       parser.parseMethodResponse( stringOrReadable )[1]
71     end
73   end # class Marshal
75 end