1 | #
|
---|
2 | # Marshalling of XML-RPC methodCall and methodResponse
|
---|
3 | #
|
---|
4 | # Copyright (C) 2001, 2002, 2003 by Michael Neumann ([email protected])
|
---|
5 | #
|
---|
6 | # $Id: marshal.rb 11708 2007-02-12 23:01:19Z shyouhei $
|
---|
7 | #
|
---|
8 |
|
---|
9 | require "xmlrpc/parser"
|
---|
10 | require "xmlrpc/create"
|
---|
11 | require "xmlrpc/config"
|
---|
12 | require "xmlrpc/utils"
|
---|
13 |
|
---|
14 | module XMLRPC
|
---|
15 |
|
---|
16 | class Marshal
|
---|
17 | include ParserWriterChooseMixin
|
---|
18 |
|
---|
19 | # class methods -------------------------------
|
---|
20 |
|
---|
21 | class << self
|
---|
22 |
|
---|
23 | def dump_call( methodName, *params )
|
---|
24 | new.dump_call( methodName, *params )
|
---|
25 | end
|
---|
26 |
|
---|
27 | def dump_response( param )
|
---|
28 | new.dump_response( param )
|
---|
29 | end
|
---|
30 |
|
---|
31 | def load_call( stringOrReadable )
|
---|
32 | new.load_call( stringOrReadable )
|
---|
33 | end
|
---|
34 |
|
---|
35 | def load_response( stringOrReadable )
|
---|
36 | new.load_response( stringOrReadable )
|
---|
37 | end
|
---|
38 |
|
---|
39 | alias dump dump_response
|
---|
40 | alias load load_response
|
---|
41 |
|
---|
42 | end # class self
|
---|
43 |
|
---|
44 | # instance methods ----------------------------
|
---|
45 |
|
---|
46 | def initialize( parser = nil, writer = nil )
|
---|
47 | set_parser( parser )
|
---|
48 | set_writer( writer )
|
---|
49 | end
|
---|
50 |
|
---|
51 | def dump_call( methodName, *params )
|
---|
52 | create.methodCall( methodName, *params )
|
---|
53 | end
|
---|
54 |
|
---|
55 | def dump_response( param )
|
---|
56 | create.methodResponse( ! param.kind_of?( XMLRPC::FaultException ) , param )
|
---|
57 | end
|
---|
58 |
|
---|
59 | ##
|
---|
60 | # returns [ methodname, params ]
|
---|
61 | #
|
---|
62 | def load_call( stringOrReadable )
|
---|
63 | parser.parseMethodCall( stringOrReadable )
|
---|
64 | end
|
---|
65 |
|
---|
66 | ##
|
---|
67 | # returns paramOrFault
|
---|
68 | #
|
---|
69 | def load_response( stringOrReadable )
|
---|
70 | parser.parseMethodResponse( stringOrReadable )[1]
|
---|
71 | end
|
---|
72 |
|
---|
73 | end # class Marshal
|
---|
74 |
|
---|
75 | end
|
---|
76 |
|
---|