Class: SOAP::Mapping::WSDLEncodedRegistry

Inherits:
Registry show all
Includes:
TraverseSupport
Defined in:
lib/soap/mapping/wsdlencodedregistry.rb

Constant Summary

Constants inherited from Registry

Registry::ArrayFactory, Registry::Base64Factory, Registry::BasetypeFactory, Registry::DateTimeFactory, Registry::HashFactory, Registry::RubyOriginalMap, Registry::SOAPBaseMap, Registry::StringFactory, Registry::TypedArrayFactory, Registry::TypedStructFactory, Registry::URIFactory

Instance Attribute Summary collapse

Attributes inherited from Registry

#default_factory

Instance Method Summary collapse

Methods included from TraverseSupport

#mark_marshalled_obj, #mark_unmarshalled_obj

Methods inherited from Registry

#add, #find_mapped_obj_class, #find_mapped_soap_class

Constructor Details

#initialize(definedtypes = XSD::NamedElements::Empty) ⇒ WSDLEncodedRegistry

Returns a new instance of WSDLEncodedRegistry.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 28

def initialize(definedtypes = XSD::NamedElements::Empty)
  @definedtypes = definedtypes
  # @definedelements = definedelements  needed?
  @excn_handler_obj2soap = nil
  @excn_handler_soap2obj = nil
  # For mapping AnyType element.
  @rubytype_factory = RubytypeFactory.new(
    :allow_untyped_struct => true,
    :allow_original_mapping => true
  )
  @schema_element_cache = {}
end

Instance Attribute Details

#definedelementsObject (readonly)

Returns the value of attribute definedelements



23
24
25
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 23

def definedelements
  @definedelements
end

#definedtypesObject (readonly)

Returns the value of attribute definedtypes



24
25
26
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 24

def definedtypes
  @definedtypes
end

#excn_handler_obj2soapObject

Returns the value of attribute excn_handler_obj2soap



25
26
27
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 25

def excn_handler_obj2soap
  @excn_handler_obj2soap
end

#excn_handler_soap2objObject

Returns the value of attribute excn_handler_soap2obj



26
27
28
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 26

def excn_handler_soap2obj
  @excn_handler_soap2obj
end

Instance Method Details

#obj2soap(obj, qname = nil) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 41

def obj2soap(obj, qname = nil)
  soap_obj = nil
  if type = @definedtypes[qname]
    soap_obj = obj2typesoap(obj, type)
  else
    soap_obj = any2soap(obj, qname)
  end
  return soap_obj if soap_obj
  if @excn_handler_obj2soap
    soap_obj = @excn_handler_obj2soap.call(obj) { |yield_obj|
      Mapping._obj2soap(yield_obj, self)
    }
    return soap_obj if soap_obj
  end
  if qname
    raise MappingError.new("cannot map #{obj.class.name} as #{qname}")
  else
    raise MappingError.new("cannot map #{obj.class.name} to SOAP/OM")
  end
end

#soap2obj(node, obj_class = nil) ⇒ Object

map anything for now: must refer WSDL while mapping. [ToDo]

Raises:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 63

def soap2obj(node, obj_class = nil)
  begin
    return any2obj(node, obj_class)
  rescue MappingError
  end
  if @excn_handler_soap2obj
    begin
      return @excn_handler_soap2obj.call(node) { |yield_node|
   Mapping._soap2obj(yield_node, self)
 }
    rescue Exception
    end
  end
  raise MappingError.new("cannot map #{node.type.name} to Ruby object")
end