diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xmlrpc/create.rb | 17 | ||||
-rw-r--r-- | lib/xmlrpc/parser.rb | 38 | ||||
-rw-r--r-- | lib/xmlrpc/utils.rb | 7 |
3 files changed, 31 insertions, 31 deletions
diff --git a/lib/xmlrpc/create.rb b/lib/xmlrpc/create.rb index 072e72ab46..0bfa4ab551 100644 --- a/lib/xmlrpc/create.rb +++ b/lib/xmlrpc/create.rb @@ -86,6 +86,18 @@ module XMLRPC end # class XMLParser + Classes = [Simple, XMLParser] + + # yields an instance of each installed XML writer + def self.each_installed_writer + XMLRPC::XMLWriter::Classes.each do |klass| + begin + yield klass.new + rescue LoadError + end + end + end + end # module XMLWriter class Create @@ -248,7 +260,10 @@ module XMLRPC if Config::ENABLE_MARSHALLING and param.class.included_modules.include? XMLRPC::Marshallable # convert Ruby object into Hash ret = {"___class___" => param.class.name} - param.__get_instance_variables.each {|name, val| + param.instance_variables.each {|v| + name = v[1..-1] + val = param.instance_variable_get(v) + if val.nil? ret[name] = val if Config::ENABLE_NIL_CREATE else diff --git a/lib/xmlrpc/parser.rb b/lib/xmlrpc/parser.rb index da214ba1ce..ed0e9a66f3 100644 --- a/lib/xmlrpc/parser.rb +++ b/lib/xmlrpc/parser.rb @@ -112,31 +112,13 @@ module XMLRPC begin mod = Module klass.split("::").each {|const| mod = mod.const_get(const.strip)} - - Thread.critical = true - # let initialize take 0 parameters - mod.module_eval %{ - begin - alias __initialize initialize - rescue NameError - end - def initialize; end - } - - obj = mod.new - - # restore old initialize - mod.module_eval %{ - undef initialize - begin - alias initialize __initialize - rescue NameError - end - } - Thread.critical = false + obj = mod.allocate + hash.delete "___class___" - hash.each {|k,v| obj.__set_instance_variable(k, v) } + hash.each {|key, value| + obj.instance_variable_set("@#{ key }", value) if key =~ /^([\w_][\w_0-9]*)$/ + } obj rescue hash @@ -801,6 +783,16 @@ module XMLRPC NQXMLStreamParser, NQXMLTreeParser, REXMLStreamParser, XMLScanStreamParser] + # yields an instance of each installed parser + def self.each_installed_parser + XMLRPC::XMLParser::Classes.each do |klass| + begin + yield klass.new + rescue LoadError + end + end + end + end # module XMLParser diff --git a/lib/xmlrpc/utils.rb b/lib/xmlrpc/utils.rb index 14dd08b21d..d542cfe4e6 100644 --- a/lib/xmlrpc/utils.rb +++ b/lib/xmlrpc/utils.rb @@ -17,13 +17,6 @@ module XMLRPC # key/value pair "___class___" => ClassName # module Marshallable - def __get_instance_variables - instance_variables.collect {|var| [var[1..-1], eval(var)] } - end - - def __set_instance_variable(key, value) - eval("@#$1 = value") if key =~ /^([\w_][\w_0-9]*)$/ - end end |