Class: SOAP::Mapping::WSDLLiteralRegistry
- Inherits:
-
LiteralRegistry
- Object
- LiteralRegistry
- SOAP::Mapping::WSDLLiteralRegistry
- Defined in:
- lib/soap/mapping/wsdlliteralregistry.rb
Instance Attribute Summary collapse
-
#definedelements ⇒ Object
readonly
Returns the value of attribute definedelements.
-
#definedtypes ⇒ Object
readonly
Returns the value of attribute definedtypes.
Attributes inherited from LiteralRegistry
#excn_handler_obj2soap, #excn_handler_soap2obj
Instance Method Summary collapse
-
#initialize(definedtypes = XSD::NamedElements::Empty, definedelements = XSD::NamedElements::Empty) ⇒ WSDLLiteralRegistry
constructor
A new instance of WSDLLiteralRegistry.
- #obj2soap(obj, qname, obj_class = nil) ⇒ Object
-
#soap2obj(node, obj_class = nil) ⇒ Object
node should be a SOAPElement.
Methods included from RegistrySupport
#add_attributes2soap, #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
Constructor Details
#initialize(definedtypes = XSD::NamedElements::Empty, definedelements = XSD::NamedElements::Empty) ⇒ WSDLLiteralRegistry
Returns a new instance of WSDLLiteralRegistry.
26 27 28 29 30 31 |
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 26 def initialize(definedtypes = XSD::NamedElements::Empty, definedelements = XSD::NamedElements::Empty) super() @definedtypes = definedtypes @definedelements = definedelements end |
Instance Attribute Details
#definedelements ⇒ Object (readonly)
Returns the value of attribute definedelements.
23 24 25 |
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 23 def definedelements @definedelements end |
#definedtypes ⇒ Object (readonly)
Returns the value of attribute definedtypes.
24 25 26 |
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 24 def definedtypes @definedtypes end |
Instance Method Details
#obj2soap(obj, qname, obj_class = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 33 def obj2soap(obj, qname, obj_class = nil) soap_obj = nil if obj.is_a?(SOAPElement) soap_obj = obj elsif eledef = @definedelements[qname] soap_obj = obj2elesoap(obj, eledef) elsif type = @definedtypes[qname] soap_obj = obj2typesoap(obj, type) else soap_obj = any2soap(obj, qname, obj_class) end return soap_obj if soap_obj if @excn_handler_obj2soap soap_obj = @excn_handler_obj2soap.call(obj) { |yield_obj| Mapping.obj2soap(yield_obj, nil, nil, MAPPING_OPT) } return soap_obj if soap_obj end raise MappingError.new("cannot map #{obj.class.name} as #{qname}") end |
#soap2obj(node, obj_class = nil) ⇒ Object
node should be a SOAPElement
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/soap/mapping/wsdlliteralregistry.rb', line 55 def soap2obj(node, obj_class = nil) cause = nil begin return any2obj(node, obj_class) rescue MappingError cause = $! end if @excn_handler_soap2obj begin return @excn_handler_soap2obj.call(node) { |yield_node| Mapping.soap2obj(yield_node, nil, nil, MAPPING_OPT) } rescue Exception end end if node.respond_to?(:type) raise MappingError.new("cannot map #{node.type.name} to Ruby object", cause) else raise MappingError.new("cannot map #{node.elename.name} to Ruby object", cause) end end |