/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. require "xmlrpc/parser"
  9. require "xmlrpc/create"
  10. require "xmlrpc/config"
  11. require "xmlrpc/utils"
  12. module XMLRPC
  13. class Marshal
  14. include ParserWriterChooseMixin
  15. # class methods -------------------------------
  16. class << self
  17. def dump_call( methodName, *params )
  18. new.dump_call( methodName, *params )
  19. end
  20. def dump_response( param )
  21. new.dump_response( param )
  22. end
  23. def load_call( stringOrReadable )
  24. new.load_call( stringOrReadable )
  25. end
  26. def load_response( stringOrReadable )
  27. new.load_response( stringOrReadable )
  28. end
  29. alias dump dump_response
  30. alias load load_response
  31. end # class self
  32. # instance methods ----------------------------
  33. def initialize( parser = nil, writer = nil )
  34. set_parser( parser )
  35. set_writer( writer )
  36. end
  37. def dump_call( methodName, *params )
  38. create.methodCall( methodName, *params )
  39. end
  40. def dump_response( param )
  41. create.methodResponse( ! param.kind_of?( XMLRPC::FaultException ) , param )
  42. end
  43. ##
  44. # returns [ methodname, params ]
  45. #
  46. def load_call( stringOrReadable )
  47. parser.parseMethodCall( stringOrReadable )
  48. end
  49. ##
  50. # returns paramOrFault
  51. #
  52. def load_response( stringOrReadable )
  53. parser.parseMethodResponse( stringOrReadable )[1]
  54. end
  55. end # class Marshal
  56. end