Class: SOAP::Mapping::WSDLEncodedRegistry

Inherits:
EncodedRegistry show all
Defined in:
lib/soap/mapping/wsdlencodedregistry.rb

Constant Summary

Constants inherited from EncodedRegistry

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

Instance Attribute Summary collapse

Attributes inherited from EncodedRegistry

#default_factory, #excn_handler_obj2soap, #excn_handler_soap2obj

Instance Method Summary collapse

Methods inherited from EncodedRegistry

#add, #find_mapped_obj_class, #find_mapped_soap_class

Methods included from RegistrySupport

#add_attributes2soap, #add_definedattributes2soap, #base2obj, #base2soap, #elename_schema_definition_from_class, #find_node_definition, #find_schema_definition, #get_xmlattr_value, #is_stubobj_elements_for_array, #register, #schema_definition_from_class, #schema_definition_from_elename, #schema_definition_from_type

Methods included from TraverseSupport

#mark_marshalled_obj, #mark_unmarshalled_obj

Constructor Details

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

Returns a new instance of WSDLEncodedRegistry.



25
26
27
28
29
30
31
32
33
34
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 25

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

Instance Attribute Details

#definedelementsObject (readonly)

Returns the value of attribute definedelements.



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

def definedelements
  @definedelements
end

#definedtypesObject (readonly)

Returns the value of attribute definedtypes.



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

def definedtypes
  @definedtypes
end

Instance Method Details

#obj2soap(obj, qname = nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/soap/mapping/wsdlencodedregistry.rb', line 36

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:



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

def soap2obj(node, obj_class = nil)
  cause = nil
  begin
    unless obj_class
      typestr = Mapping.safeconstname(node.elename.name)
      obj_class = Mapping.class_from_name(typestr)
    end
    return Mapping._soap2obj(node, Mapping::DefaultRegistry, obj_class)
  rescue MappingError
    cause = $!
  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", cause)
end