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