class SOAP::Mapping::Object

For anyType object: SOAP::Mapping::Object not ::Object

Public Class Methods

new() click to toggle source
# File lib/soap/mapping/registry.rb, line 35
def initialize
  @__xmlele_type = {}
  @__xmlele = []
  @__xmlattr = {}
end

Public Instance Methods

[](qname) click to toggle source
# File lib/soap/mapping/registry.rb, line 54
def [](qname)
  qname = Mapping.to_qname(qname)
  @__xmlele.each do |k, v|
    return v if k == qname
  end
  # fallback
  @__xmlele.each do |k, v|
    return v if k.name == qname.name
  end
  nil
end
[]=(qname, value) click to toggle source
# File lib/soap/mapping/registry.rb, line 66
def []=(qname, value)
  qname = Mapping.to_qname(qname)
  found = false
  @__xmlele.each do |pair|
    if pair[0] == qname
      found = true
      pair[1] = value
    end
  end
  unless found
    __define_attr_accessor(qname)
    @__xmlele << [qname, value]
  end
  @__xmlele_type[qname] = :single
end
__add_xmlele_value(qname, value) click to toggle source
# File lib/soap/mapping/registry.rb, line 82
def __add_xmlele_value(qname, value)
  found = false
  @__xmlele.map! do |k, v|
    if k == qname
      found = true
      [k, __set_xmlele_value(k, v, value)]
    else
      [k, v]
    end
  end
  unless found
    __define_attr_accessor(qname)
    @__xmlele << [qname, value]
    @__xmlele_type[qname] = :single
  end
  value
end
__xmlattr() click to toggle source
# File lib/soap/mapping/registry.rb, line 46
def __xmlattr
  @__xmlattr
end
__xmlele() click to toggle source
# File lib/soap/mapping/registry.rb, line 50
def __xmlele
  @__xmlele
end
inspect() click to toggle source
# File lib/soap/mapping/registry.rb, line 41
def inspect
  sprintf("#<%s:0x%x%s>", self.class.name, __id__,
    @__xmlele.collect { |name, value| " #{name}=#{value.inspect}" }.join)
end
marshal_load(dumpobj) click to toggle source
# File lib/soap/mapping/registry.rb, line 100
def marshal_load(dumpobj)
  __import(dumpobj)
end

Private Instance Methods

__define_attr_accessor(qname) click to toggle source

Mapping.define_attr_accessor calls define_method with proc and it exhausts much memory for each singleton Object. just instance_eval instead of it.

# File lib/soap/mapping/registry.rb, line 108
  def __define_attr_accessor(qname)
    # untaint depends GenSupport.safemethodname
    name = Mapping.safemethodname(qname.name).untaint
    # untaint depends on QName#dump
    qnamedump = qname.dump.untaint
    singleton = false
    unless self.respond_to?(name)
      singleton = true
      instance_eval <<-EOS
        def #{name}
          self[#{qnamedump}]
        end
      EOS
    end
    unless self.respond_to?(name + "=")
      singleton = true
      instance_eval <<-EOS
        def #{name}=(value)
          self[#{qnamedump}] = value
        end
      EOS
    end
    if singleton && !self.respond_to?(:marshal_dump)
      instance_eval <<-EOS
        def marshal_dump
          __export
        end
      EOS
    end
  end
__export() click to toggle source
# File lib/soap/mapping/registry.rb, line 152
def __export
  dumpobj = ::SOAP::Mapping::Object.new
  dumpobj.__xmlele.replace(@__xmlele)
  dumpobj.__xmlattr.replace(@__xmlattr)
  dumpobj
end
__import(dumpobj) click to toggle source
# File lib/soap/mapping/registry.rb, line 159
def __import(dumpobj)
  @__xmlele_type = {}
  @__xmlele = []
  @__xmlattr = {}
  dumpobj.__xmlele.each do |qname, value|
    __add_xmlele_value(qname, value)
  end
  @__xmlattr.replace(dumpobj.__xmlattr)
end
__set_xmlele_value(key, org, value) click to toggle source
# File lib/soap/mapping/registry.rb, line 139
def __set_xmlele_value(key, org, value)
  case @__xmlele_type[key]
  when :multi
    org << value
    org
  when :single
    @__xmlele_type[key] = :multi
    [org, value]
  else
    raise RuntimeError.new("unknown type")
  end
end