Class: SOAP::Mapping::LiteralRegistry

Inherits:
Object
  • Object
show all
Includes:
RegistrySupport
Defined in:
lib/soap/mapping/literalregistry.rb

Direct Known Subclasses

WSDLLiteralRegistry

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Constructor Details

#initializeLiteralRegistry

Returns a new instance of LiteralRegistry.



27
28
29
30
31
# File 'lib/soap/mapping/literalregistry.rb', line 27

def initialize
  super()
  @excn_handler_obj2soap = nil
  @excn_handler_soap2obj = nil
end

Instance Attribute Details

#excn_handler_obj2soapObject

Returns the value of attribute excn_handler_obj2soap.



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

def excn_handler_obj2soap
  @excn_handler_obj2soap
end

#excn_handler_soap2objObject

Returns the value of attribute excn_handler_soap2obj.



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

def excn_handler_soap2obj
  @excn_handler_soap2obj
end

Instance Method Details

#obj2soap(obj, qname, obj_class = nil) ⇒ Object

Raises:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/soap/mapping/literalregistry.rb', line 33

def obj2soap(obj, qname, obj_class = nil)
  soap_obj = nil
  if obj.is_a?(SOAPElement)
    soap_obj = obj
  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

Raises:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/soap/mapping/literalregistry.rb', line 51

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
  raise MappingError.new("cannot map #{node.elename.name}/#{node.type.name} to Ruby object", cause)
end