PageRenderTime 106ms CodeModel.GetById 99ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/Ruby/lib/ruby/1.8/xmlrpc/marshal.rb

http://github.com/agross/netopenspace
Ruby | 76 lines | 41 code | 20 blank | 15 comment | 0 complexity | 5203a6239cc90bd027b25eb2d9168aff MD5 | raw file
 1#
 2# Marshalling of XML-RPC methodCall and methodResponse
 3# 
 4# Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
 5#
 6# $Id: marshal.rb 11708 2007-02-12 23:01:19Z shyouhei $
 7#
 8
 9require "xmlrpc/parser"
10require "xmlrpc/create"
11require "xmlrpc/config"
12require "xmlrpc/utils"
13
14module 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
75end
76