In: |
xmlrpc/parser.rb
|
# File xmlrpc/parser.rb, line 73 def self.boolean(str) case str when "0" then false when "1" then true else raise "RPC-value of type boolean is wrong" end end
# File xmlrpc/parser.rb, line 86 def self.dateTime(str) if str =~ /^(-?\d\d\d\d)(\d\d)(\d\d)T(\d\d):(\d\d):(\d\d)$/ then # TODO: Time.gm ??? .local ??? a = [$1, $2, $3, $4, $5, $6].collect{|i| i.to_i} XMLRPC::DateTime.new(*a) #if a[0] >= 1970 then # Time.gm(*a) #else # Date.new(*a[0,3]) #end else raise "wrong dateTime.iso8601 format" end end
# File xmlrpc/parser.rb, line 106 def self.struct(hash) # convert to marhalled object klass = hash["___class___"] if klass.nil? or Config::ENABLE_MARSHALLING == false hash else 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 hash.delete "___class___" hash.each {|k,v| obj.__set_instance_variable(k, v) } obj rescue hash end end end
# File xmlrpc/parser.rb, line 147 def self.fault(hash) if hash.kind_of? Hash and hash.size == 2 and hash.has_key? "faultCode" and hash.has_key? "faultString" and hash["faultCode"].kind_of? Integer and hash["faultString"].kind_of? String XMLRPC::FaultException.new(hash["faultCode"], hash["faultString"]) else raise "wrong fault-structure: #{hash.inspect}" end end