| Class | SOAP::Mapping::Registry |
| In: |
lib/soap/mapping/registry.rb
|
| Parent: | Object |
| StringFactory | = | StringFactory_.new |
| BasetypeFactory | = | BasetypeFactory_.new |
| DateTimeFactory | = | DateTimeFactory_.new |
| ArrayFactory | = | ArrayFactory_.new |
| Base64Factory | = | Base64Factory_.new |
| URIFactory | = | URIFactory_.new |
| TypedArrayFactory | = | TypedArrayFactory_.new |
| TypedStructFactory | = | TypedStructFactory_.new |
| HashFactory | = | HashFactory_.new |
| SOAPBaseMap | = | [ [::NilClass, ::SOAP::SOAPNil, BasetypeFactory], [::TrueClass, ::SOAP::SOAPBoolean, BasetypeFactory], [::FalseClass, ::SOAP::SOAPBoolean, BasetypeFactory], [::String, ::SOAP::SOAPString, StringFactory], [::DateTime, ::SOAP::SOAPDateTime, DateTimeFactory], [::Date, ::SOAP::SOAPDate, DateTimeFactory], [::Time, ::SOAP::SOAPDateTime, DateTimeFactory], [::Time, ::SOAP::SOAPTime, DateTimeFactory], [::Float, ::SOAP::SOAPDouble, BasetypeFactory, {:derived_class => true}], [::Float, ::SOAP::SOAPFloat, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPInt, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPLong, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPShort, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPByte, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPNonPositiveInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPNegativeInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPNonNegativeInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPPositiveInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPUnsignedLong, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPUnsignedInt, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPUnsignedShort, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPUnsignedByte, BasetypeFactory, {:derived_class => true}], [::URI::Generic, ::SOAP::SOAPAnyURI, URIFactory, {:derived_class => true}], [::String, ::SOAP::SOAPBase64, Base64Factory], [::String, ::SOAP::SOAPHexBinary, Base64Factory], [::String, ::SOAP::SOAPDecimal, BasetypeFactory], [::String, ::SOAP::SOAPDuration, BasetypeFactory], [::String, ::SOAP::SOAPGYearMonth, BasetypeFactory], [::String, ::SOAP::SOAPGYear, BasetypeFactory], [::String, ::SOAP::SOAPGMonthDay, BasetypeFactory], [::String, ::SOAP::SOAPGDay, BasetypeFactory], [::String, ::SOAP::SOAPGMonth, BasetypeFactory], [::String, ::SOAP::SOAPQName, BasetypeFactory], [::Hash, ::SOAP::SOAPArray, HashFactory], [::Hash, ::SOAP::SOAPStruct, HashFactory], [::Array, ::SOAP::SOAPArray, ArrayFactory, {:derived_class => true}], [::SOAP::Mapping::SOAPException, ::SOAP::SOAPStruct, TypedStructFactory, {:type => XSD::QName.new(RubyCustomTypeNamespace, "SOAPException")}], ] |
| RubyOriginalMap | = | [ [::NilClass, ::SOAP::SOAPNil, BasetypeFactory], [::TrueClass, ::SOAP::SOAPBoolean, BasetypeFactory], [::FalseClass, ::SOAP::SOAPBoolean, BasetypeFactory], [::String, ::SOAP::SOAPString, StringFactory], [::DateTime, ::SOAP::SOAPDateTime, DateTimeFactory], [::Date, ::SOAP::SOAPDate, DateTimeFactory], [::Time, ::SOAP::SOAPDateTime, DateTimeFactory], [::Time, ::SOAP::SOAPTime, DateTimeFactory], [::Float, ::SOAP::SOAPDouble, BasetypeFactory, {:derived_class => true}], [::Float, ::SOAP::SOAPFloat, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPInt, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPLong, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPShort, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPByte, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPNonPositiveInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPNegativeInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPNonNegativeInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPPositiveInteger, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPUnsignedLong, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPUnsignedInt, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPUnsignedShort, BasetypeFactory, {:derived_class => true}], [::Integer, ::SOAP::SOAPUnsignedByte, BasetypeFactory, {:derived_class => true}], [::URI::Generic, ::SOAP::SOAPAnyURI, URIFactory, {:derived_class => true}], [::String, ::SOAP::SOAPBase64, Base64Factory], [::String, ::SOAP::SOAPHexBinary, Base64Factory], [::String, ::SOAP::SOAPDecimal, BasetypeFactory], [::String, ::SOAP::SOAPDuration, BasetypeFactory], [::String, ::SOAP::SOAPGYearMonth, BasetypeFactory], [::String, ::SOAP::SOAPGYear, BasetypeFactory], [::String, ::SOAP::SOAPGMonthDay, BasetypeFactory], [::String, ::SOAP::SOAPGDay, BasetypeFactory], [::String, ::SOAP::SOAPGMonth, BasetypeFactory], [::String, ::SOAP::SOAPQName, BasetypeFactory], [::Hash, ::SOAP::SOAPArray, HashFactory], [::Hash, ::SOAP::SOAPStruct, HashFactory], # Does not allow Array's subclass here. [::Array, ::SOAP::SOAPArray, ArrayFactory], [::SOAP::Mapping::SOAPException, ::SOAP::SOAPStruct, TypedStructFactory, {:type => XSD::QName.new(RubyCustomTypeNamespace, "SOAPException")}], ] |
| default_factory | [RW] | |
| excn_handler_obj2soap | [RW] | |
| excn_handler_soap2obj | [RW] |
# File lib/soap/mapping/registry.rb, line 393
393: def initialize(config = {})
394: @config = config
395: @map = Map.new(self)
396: if @config[:allow_original_mapping]
397: @allow_original_mapping = true
398: @map.init(RubyOriginalMap)
399: else
400: @allow_original_mapping = false
401: @map.init(SOAPBaseMap)
402: end
403: @allow_untyped_struct = @config.key?(:allow_untyped_struct) ?
404: @config[:allow_untyped_struct] : true
405: @rubytype_factory = RubytypeFactory.new(
406: :allow_untyped_struct => @allow_untyped_struct,
407: :allow_original_mapping => @allow_original_mapping
408: )
409: @default_factory = @rubytype_factory
410: @excn_handler_obj2soap = nil
411: @excn_handler_soap2obj = nil
412: end
# File lib/soap/mapping/registry.rb, line 414
414: def add(obj_class, soap_class, factory, info = nil)
415: @map.add(obj_class, soap_class, factory, info)
416: end
# File lib/soap/mapping/registry.rb, line 441
441: def find_mapped_obj_class(soap_class)
442: @map.find_mapped_obj_class(soap_class)
443: end
# File lib/soap/mapping/registry.rb, line 437
437: def find_mapped_soap_class(obj_class)
438: @map.find_mapped_soap_class(obj_class)
439: end
# File lib/soap/mapping/registry.rb, line 428
428: def soap2obj(node, klass = nil)
429: obj = _soap2obj(node, klass)
430: if @allow_original_mapping
431: addextend2obj(obj, node.extraattr[RubyExtendName])
432: addiv2obj(obj, node.extraattr[RubyIVarName])
433: end
434: obj
435: end
# File lib/soap/mapping/registry.rb, line 447
447: def _obj2soap(obj)
448: ret = nil
449: if obj.is_a?(SOAPStruct) or obj.is_a?(SOAPArray)
450: obj.replace do |ele|
451: Mapping._obj2soap(ele, self)
452: end
453: return obj
454: elsif obj.is_a?(SOAPBasetype)
455: return obj
456: end
457: begin
458: ret = @map.obj2soap(obj) ||
459: @default_factory.obj2soap(nil, obj, nil, self)
460: return ret if ret
461: rescue MappingError
462: end
463: if @excn_handler_obj2soap
464: ret = @excn_handler_obj2soap.call(obj) { |yield_obj|
465: Mapping._obj2soap(yield_obj, self)
466: }
467: return ret if ret
468: end
469: raise MappingError.new("Cannot map #{ obj.class.name } to SOAP/OM.")
470: end
Might return nil as a mapping result.
# File lib/soap/mapping/registry.rb, line 473
473: def _soap2obj(node, klass = nil)
474: if node.extraattr.key?(RubyTypeName)
475: conv, obj = @rubytype_factory.soap2obj(nil, node, nil, self)
476: return obj if conv
477: else
478: conv, obj = @map.soap2obj(node, klass)
479: return obj if conv
480: conv, obj = @default_factory.soap2obj(nil, node, nil, self)
481: return obj if conv
482: end
483: if @excn_handler_soap2obj
484: begin
485: return @excn_handler_soap2obj.call(node) { |yield_node|
486: Mapping._soap2obj(yield_node, self)
487: }
488: rescue Exception
489: end
490: end
491: raise MappingError.new("Cannot map #{ node.type.name } to Ruby object.")
492: end
(class < false; self; end).ancestors includes "TrueClass" under 1.6…
# File lib/soap/mapping/registry.rb, line 512
512: def addextend2obj(obj, attr)
513: return unless attr
514: attr.split(/ /).reverse_each do |mstr|
515: m = Mapping.module_from_name(mstr)
516: obj.extend(m)
517: end
518: end
# File lib/soap/mapping/registry.rb, line 504
504: def addextend2obj(obj, attr)
505: return unless attr
506: attr.split(/ /).reverse_each do |mstr|
507: obj.extend(Mapping.module_from_name(mstr))
508: end
509: end
# File lib/soap/mapping/registry.rb, line 521
521: def addextend2soap(node, obj)
522: return if obj.is_a?(Symbol) or obj.is_a?(Fixnum)
523: list = (class << obj; self; end).ancestors - obj.class.ancestors
524: unless list.empty?
525: node.extraattr[RubyExtendName] = list.collect { |c|
526: if c.name.empty?
527: raise TypeError.new("singleton can't be dumped #{ obj }")
528: end
529: c.name
530: }.join(" ")
531: end
532: end