Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1725

Show
Ignore:
Timestamp:
09/25/06 13:14:49 (2 years ago)
Author:
nahi
Message:

SOAP::Mapping::Object could not be dumped with Ruby's Marshal; 'singleton can't be dumped'.
adoption of instance_eval instead of define_method for #224 causes this problem.
added custom marshalling methods.
closes #266.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/mapping/registry.rb

    r1724 r1725  
    3232 
    3333# For anyType object: SOAP::Mapping::Object not ::Object 
    34 class Object; include Marshallable 
     34class Object 
    3535  def initialize 
    3636    @__xmlele_type = {} 
     
    102102  end 
    103103 
     104  def marshal_load(dumpobj) 
     105    __import(dumpobj) 
     106  end 
     107 
    104108private 
    105109 
     
    109113    # untaint depends GenSupport.safemethodname 
    110114    name = XSD::CodeGen::GenSupport.safemethodname(qname.name).untaint 
    111     # untaint depends QName#dump 
     115    # untaint depends on QName#dump 
    112116    qnamedump = qname.dump.untaint 
     117    singleton = false 
    113118    unless self.respond_to?(name) 
     119      singleton = true 
    114120      instance_eval <<-EOS 
    115121        def #{name} 
     
    119125    end 
    120126    unless self.respond_to?(name + "=") 
     127      singleton = true 
    121128      instance_eval <<-EOS 
    122129        def #{name}=(value) 
    123130          self[#{qnamedump}] = value 
     131        end 
     132      EOS 
     133    end 
     134    if singleton && !self.respond_to?(:marshal_dump) 
     135      instance_eval <<-EOS 
     136        def marshal_dump 
     137          __export 
    124138        end 
    125139      EOS 
     
    139153    end 
    140154  end 
     155 
     156  def __export 
     157    dumpobj = ::SOAP::Mapping::Object.new 
     158    dumpobj.__xmlele.replace(@__xmlele) 
     159    dumpobj.__xmlattr.replace(@__xmlattr) 
     160    dumpobj 
     161  end 
     162 
     163  def __import(dumpobj) 
     164    @__xmlele_type = {} 
     165    @__xmlele = [] 
     166    @__xmlattr = {} 
     167    dumpobj.__xmlele.each do |qname, value| 
     168      __add_xmlele_value(qname, value) 
     169    end 
     170    @__xmlattr.replace(dumpobj.__xmlattr) 
     171  end 
    141172end 
    142173