Class: SOAP::Mapping::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/soap/mapping/registry.rb

Direct Known Subclasses

WSDLEncodedRegistry, WSDLLiteralRegistry

Defined Under Namespace

Classes: Map

Constant Summary collapse

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")}],
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Registry

Returns a new instance of Registry.



392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/soap/mapping/registry.rb', line 392

def initialize(config = {})
  @config = config
  @map = Map.new(self)
  if @config[:allow_original_mapping]
    @allow_original_mapping = true
    @map.init(RubyOriginalMap)
  else
    @allow_original_mapping = false
    @map.init(SOAPBaseMap)
  end
  @allow_untyped_struct = @config.key?(:allow_untyped_struct) ?
    @config[:allow_untyped_struct] : true
  @rubytype_factory = RubytypeFactory.new(
    :allow_untyped_struct => @allow_untyped_struct,
    :allow_original_mapping => @allow_original_mapping
  )
  @default_factory = @rubytype_factory
  @excn_handler_obj2soap = nil
  @excn_handler_soap2obj = nil
end

Instance Attribute Details

#default_factoryObject

Returns the value of attribute default_factory.



388
389
390
# File 'lib/soap/mapping/registry.rb', line 388

def default_factory
  @default_factory
end

#excn_handler_obj2soapObject

Returns the value of attribute excn_handler_obj2soap.



389
390
391
# File 'lib/soap/mapping/registry.rb', line 389

def excn_handler_obj2soap
  @excn_handler_obj2soap
end

#excn_handler_soap2objObject

Returns the value of attribute excn_handler_soap2obj.



390
391
392
# File 'lib/soap/mapping/registry.rb', line 390

def excn_handler_soap2obj
  @excn_handler_soap2obj
end

Instance Method Details

#add(obj_class, soap_class, factory, info = nil) ⇒ Object Also known as: set



413
414
415
# File 'lib/soap/mapping/registry.rb', line 413

def add(obj_class, soap_class, factory, info = nil)
  @map.add(obj_class, soap_class, factory, info)
end

#find_mapped_obj_class(soap_class) ⇒ Object



440
441
442
# File 'lib/soap/mapping/registry.rb', line 440

def find_mapped_obj_class(soap_class)
  @map.find_mapped_obj_class(soap_class)
end

#find_mapped_soap_class(obj_class) ⇒ Object



436
437
438
# File 'lib/soap/mapping/registry.rb', line 436

def find_mapped_soap_class(obj_class)
  @map.find_mapped_soap_class(obj_class)
end

#obj2soap(obj, type_qname = nil) ⇒ Object

general Registry ignores type_qname



419
420
421
422
423
424
425
# File 'lib/soap/mapping/registry.rb', line 419

def obj2soap(obj, type_qname = nil)
  soap = _obj2soap(obj)
  if @allow_original_mapping
    addextend2soap(soap, obj)
  end
  soap
end

#soap2obj(node, klass = nil) ⇒ Object



427
428
429
430
431
432
433
434
# File 'lib/soap/mapping/registry.rb', line 427

def soap2obj(node, klass = nil)
  obj = _soap2obj(node, klass)
  if @allow_original_mapping
    addextend2obj(obj, node.extraattr[RubyExtendName])
    addiv2obj(obj, node.extraattr[RubyIVarName])
  end
  obj
end