### Home Classes Methods

### In Files

- lib/soap/mapping/rubytypeFactory.rb

### Parent

SOAP::Mapping::Factory

### Methods

- ::new
- #obj2soap
- #soap2obj

### Files

- tags

### Class/Module Index

Quicksearch

- SOAP
- SOAP::ArrayIndexOutOfBoundsError
- SOAP::ArrayStoreError
- SOAP::Attachment
- SOAP::CGIStub
- SOAP::Charset
- SOAP::Driver
- SOAP::EmptyResponseError
- SOAP::EncodingStyle
- SOAP::EncodingStyle::ASPDotNetHandler
- SOAP::EncodingStyle::ASPDotNetHandler::SOAPTemporalObject
- SOAP::EncodingStyle::ASPDotNetHandler::SOAPUnknown
- SOAP::EncodingStyle::Handler
- SOAP::EncodingStyle::Handler::EncodingStyleError
- SOAP::EncodingStyle::LiteralHandler
- SOAP::EncodingStyle::SOAPHandler
- SOAP::EncodingStyle::SOAPHandler::SOAPTemporalObject
- SOAP::EncodingStyle::SOAPHandler::SOAPUnknown
- SOAP::Env
- SOAP::Error
- SOAP::FaultCode
- SOAP::FaultError
- SOAP::Filter
- SOAP::Filter::FilterChain
- SOAP::Filter::Handler
- SOAP::Filter::StreamHandler
- SOAP::Generator
- SOAP::Generator::FormatEncodeError
- SOAP::HTTPConfigLoader
- SOAP::HTTPStreamError
- SOAP::HTTPStreamHandler
- SOAP::HTTPStreamHandler::HttpPostRequestFilter
- SOAP::Header
- SOAP::Header::Handler
- SOAP::Header::HandlerSet
- SOAP::Header::MappingHandler
- SOAP::Header::SimpleHandler
- SOAP::MIMEMessage
- SOAP::MIMEMessage::Header
- SOAP::MIMEMessage::Headers
- SOAP::MIMEMessage::MIMEMessageError
- SOAP::MIMEMessage::Part
- SOAP::MPostUnavailableError
- SOAP::Mapping
- SOAP::Mapping::ArrayFactory_
- SOAP::Mapping::AttachmentFactory
- SOAP::Mapping::Base64Factory_
- SOAP::Mapping::BasetypeFactory_
- SOAP::Mapping::DateTimeFactory_
- SOAP::Mapping::EncodedRegistry
- SOAP::Mapping::EncodedRegistry::Map
- SOAP::Mapping::Factory
- SOAP::Mapping::FixnumFactory_
- SOAP::Mapping::HashFactory_
- SOAP::Mapping::LiteralRegistry
- SOAP::Mapping::MappedException
- SOAP::Mapping::MappingError
- SOAP::Mapping::Object
- SOAP::Mapping::Registry
- SOAP::Mapping::RegistrySupport
- SOAP::Mapping::RubytypeFactory
- SOAP::Mapping::SOAPException
- SOAP::Mapping::SchemaChoiceDefinition
- SOAP::Mapping::SchemaComplexTypeDefinition
- SOAP::Mapping::SchemaDefinition
- SOAP::Mapping::SchemaElementDefinition
- SOAP::Mapping::SchemaEmptyDefinition
- SOAP::Mapping::SchemaSequenceDefinition
- SOAP::Mapping::StringFactory_
- SOAP::Mapping::TraverseSupport
- SOAP::Mapping::TypedArrayFactory_
- SOAP::Mapping::TypedStructFactory_
- SOAP::Mapping::URIFactory_
- SOAP::Mapping::WSDLEncodedRegistry
- SOAP::Mapping::WSDLLiteralRegistry
- SOAP::Marshal
- SOAP::Marshal
- SOAP::Marshallable
- SOAP::NS
- SOAP::NestedException
- SOAP::NetHttpClient
- SOAP::NetHttpClient::Response
- SOAP::NetHttpClient::SessionManager
- SOAP::Parser
- SOAP::Parser::FormatDecodeError
- SOAP::Parser::ParseError
- SOAP::Parser::ParseFrame
- SOAP::Parser::ParseFrame::NodeContainer
- SOAP::Parser::UnexpectedElementError
- SOAP::PostUnavailableError
- SOAP::Processor
- SOAP::Property
- SOAP::Property::Util
- SOAP::RPC
- SOAP::RPC::CGIStub
- SOAP::RPC::CGIStub::SOAPFCGIRequest
- SOAP::RPC::CGIStub::SOAPRequest
- SOAP::RPC::CGIStub::SOAPStdinRequest
- SOAP::RPC::Driver
- SOAP::RPC::HTTPServer
- SOAP::RPC::MappingRegistry
- SOAP::RPC::MethodDefinitionError
- SOAP::RPC::ParameterError
- SOAP::RPC::Proxy
- SOAP::RPC::Proxy::Operation
- SOAP::RPC::RPCError
- SOAP::RPC::Router
- SOAP::RPC::Router::ApplicationScopeOperation
- SOAP::RPC::Router::Operation
- SOAP::RPC::Router::RequestScopeOperation
- SOAP::RPC::SOAPMethod
- SOAP::RPC::SOAPMethodRequest
- SOAP::RPC::SOAPMethodResponse
- SOAP::RPC::SOAPVoid
- SOAP::RPC::SOAPlet
- SOAP::RPC::StandaloneServer
- SOAP::RPCRoutingError
- SOAP::RPCUtils
- SOAP::ResponseFormatError
- SOAP::SOAPAnySimpleType
- SOAP::SOAPAnyURI
- SOAP::SOAPArray
- SOAP::SOAPAttachment
- SOAP::SOAPBase64
- SOAP::SOAPBasetype
- SOAP::SOAPBody
- SOAP::SOAPBoolean
- SOAP::SOAPByte
- SOAP::SOAPCompoundtype
- SOAP::SOAPDate
- SOAP::SOAPDateTime
- SOAP::SOAPDecimal
- SOAP::SOAPDouble
- SOAP::SOAPDuration
- SOAP::SOAPENTITIES
- SOAP::SOAPENTITY
- SOAP::SOAPElement
- SOAP::SOAPEnvelope
- SOAP::SOAPEnvelopeElement
- SOAP::SOAPExternalReference
- SOAP::SOAPFault
- SOAP::SOAPFloat
- SOAP::SOAPGDay
- SOAP::SOAPGMonth
- SOAP::SOAPGMonthDay
- SOAP::SOAPGYear
- SOAP::SOAPGYearMonth
- SOAP::SOAPHeader
- SOAP::SOAPHeaderItem
- SOAP::SOAPHexBinary
- SOAP::SOAPID
- SOAP::SOAPIDREF
- SOAP::SOAPIDREFS
- SOAP::SOAPInt
- SOAP::SOAPInteger
- SOAP::SOAPLanguage
- SOAP::SOAPLong
- SOAP::SOAPModuleUtils
- SOAP::SOAPNCName
- SOAP::SOAPNMTOKEN
- SOAP::SOAPNMTOKENS
- SOAP::SOAPName
- SOAP::SOAPNameAccessible
- SOAP::SOAPNegativeInteger
- SOAP::SOAPNil
- SOAP::SOAPNonNegativeInteger
- SOAP::SOAPNonPositiveInteger
- SOAP::SOAPNormalizedString
- SOAP::SOAPPositiveInteger
- SOAP::SOAPQName
- SOAP::SOAPREXMLElementWrap
- SOAP::SOAPRawData
- SOAP::SOAPRawString
- SOAP::SOAPReference
- SOAP::SOAPShort
- SOAP::SOAPString
- SOAP::SOAPStruct
- SOAP::SOAPTime
- SOAP::SOAPToken
- SOAP::SOAPType
- SOAP::SOAPUnsignedByte
- SOAP::SOAPUnsignedInt
- SOAP::SOAPUnsignedLong
- SOAP::SOAPUnsignedShort
- SOAP::StandaloneServer
- SOAP::StreamError
- SOAP::StreamHandler
- SOAP::StreamHandler::ConnectionData
- SOAP::UnhandledMustUnderstandHeaderError
- SOAP::WSDLDriver
- SOAP::WSDLDriver::Servant__
- SOAP::WSDLDriverFactory
- SOAP::WSDLDriverFactory::FactoryError
- WSDL
- WSDL::Binding
- WSDL::Definitions
- WSDL::Documentation
- WSDL::Error
- WSDL::Import
- WSDL::Importer
- WSDL::Info
- WSDL::Message
- WSDL::Operation
- WSDL::Operation::NameInfo
- WSDL::OperationBinding
- WSDL::Param
- WSDL::Parser
- WSDL::Parser::AttributeConstraintError
- WSDL::Parser::ElementConstraintError
- WSDL::Parser::FormatDecodeError
- WSDL::Parser::ParseError
- WSDL::Parser::ParseFrame
- WSDL::Parser::UnexpectedElementError
- WSDL::Parser::UnknownAttributeError
- WSDL::Parser::UnknownElementError
- WSDL::Part
- WSDL::Port
- WSDL::PortType
- WSDL::SOAP
- WSDL::SOAP::Address
- WSDL::SOAP::Binding
- WSDL::SOAP::Body
- WSDL::SOAP::CGIStubCreator
- WSDL::SOAP::ClassDefCreator
- WSDL::SOAP::ClassDefCreatorSupport
- WSDL::SOAP::ClassNameCreator
- WSDL::SOAP::ClientSkeltonCreator
- WSDL::SOAP::DriverCreator
- WSDL::SOAP::EncodedMappingRegistryCreator
- WSDL::SOAP::Fault
- WSDL::SOAP::Header
- WSDL::SOAP::HeaderFault
- WSDL::SOAP::LiteralMappingRegistryCreator
- WSDL::SOAP::MappingRegistryCreator
- WSDL::SOAP::MappingRegistryCreatorSupport
- WSDL::SOAP::MethodDefCreator
- WSDL::SOAP::Operation
- WSDL::SOAP::Operation::OperationInfo
- WSDL::SOAP::ServantSkeltonCreator
- WSDL::SOAP::ServletStubCreator
- WSDL::SOAP::StandaloneServerStubCreator
- WSDL::SOAP::WSDL2Ruby
- WSDL::Service
- WSDL::Types
- WSDL::XMLSchema
- WSDL::XMLSchema::All
- WSDL::XMLSchema::Annotation
- WSDL::XMLSchema::Any
- WSDL::XMLSchema::AnyAttribute
- WSDL::XMLSchema::Attribute
- WSDL::XMLSchema::AttributeGroup
- WSDL::XMLSchema::Choice
- WSDL::XMLSchema::ComplexContent
- WSDL::XMLSchema::ComplexExtension
- WSDL::XMLSchema::ComplexRestriction
- WSDL::XMLSchema::ComplexType
- WSDL::XMLSchema::Content
- WSDL::XMLSchema::Element
- WSDL::XMLSchema::Enumeration
- WSDL::XMLSchema::FractionDigits
- WSDL::XMLSchema::Group
- WSDL::XMLSchema::Import
- WSDL::XMLSchema::ImportHandler
- WSDL::XMLSchema::Importer
- WSDL::XMLSchema::Include
- WSDL::XMLSchema::Length
- WSDL::XMLSchema::List
- WSDL::XMLSchema::MaxExclusive
- WSDL::XMLSchema::MaxInclusive
- WSDL::XMLSchema::MaxLength
- WSDL::XMLSchema::MinExclusive
- WSDL::XMLSchema::MinInclusive
- WSDL::XMLSchema::MinLength
- WSDL::XMLSchema::Parser
- WSDL::XMLSchema::Parser::AttributeConstraintError
- WSDL::XMLSchema::Parser::ElementConstraintError
- WSDL::XMLSchema::Parser::FormatDecodeError
- WSDL::XMLSchema::Parser::ParseError
- WSDL::XMLSchema::Parser::ParseFrame
- WSDL::XMLSchema::Parser::UnexpectedElementError
- WSDL::XMLSchema::Parser::UnknownAttributeError
- WSDL::XMLSchema::Parser::UnknownElementError
- WSDL::XMLSchema::Pattern
- WSDL::XMLSchema::Schema
- WSDL::XMLSchema::Sequence
- WSDL::XMLSchema::SimpleContent
- WSDL::XMLSchema::SimpleExtension
- WSDL::XMLSchema::SimpleRestriction
- WSDL::XMLSchema::SimpleType
- WSDL::XMLSchema::TotalDigits
- WSDL::XMLSchema::Union
- WSDL::XMLSchema::Unique
- WSDL::XMLSchema::WhiteSpace
- WSDL::XMLSchema::XSD2Ruby
- XSD
- XSD::Charset
- XSD::Charset::CharsetConversionError
- XSD::Charset::CharsetError
- XSD::Charset::UnknownCharsetError
- XSD::Charset::XSDError
- XSD::CodeGen
- XSD::CodeGen::ClassDef
- XSD::CodeGen::CommentDef
- XSD::CodeGen::GenSupport
- XSD::CodeGen::MethodDef
- XSD::CodeGen::ModuleDef
- XSD::Error
- XSD::FloatConstants
- XSD::IconvCharset
- XSD::Mapping
- XSD::Mapping::Mapper
- XSD::NS
- XSD::NS::Assigner
- XSD::NS::FormatError
- XSD::NSDBase
- XSD::NamedElements
- XSD::QName
- XSD::ValueSpaceError
- XSD::XMLParser
- XSD::XMLParser::Parser
- XSD::XMLParser::Parser::ElementConstraintError
- XSD::XMLParser::Parser::FormatDecodeError
- XSD::XMLParser::Parser::ParseError
- XSD::XMLParser::Parser::ParserError
- XSD::XMLParser::Parser::UnexpectedElementError
- XSD::XMLParser::Parser::UnknownAttributeError
- XSD::XMLParser::Parser::UnknownElementError
- XSD::XMLParser::REXMLParser
- XSD::XMLParser::XMLParser
- XSD::XMLParser::XMLParser::Listener
- XSD::XMLParser::XMLScanner
- XSD::XSDAnySimpleType
- XSD::XSDAnyURI
- XSD::XSDBase64Binary
- XSD::XSDBoolean
- XSD::XSDByte
- XSD::XSDDate
- XSD::XSDDateTime
- XSD::XSDDateTimeImpl
- XSD::XSDDecimal
- XSD::XSDDouble
- XSD::XSDDuration
- XSD::XSDENTITIES
- XSD::XSDENTITY
- XSD::XSDFloat
- XSD::XSDGDay
- XSD::XSDGMonth
- XSD::XSDGMonthDay
- XSD::XSDGYear
- XSD::XSDGYearMonth
- XSD::XSDHexBinary
- XSD::XSDID
- XSD::XSDIDREF
- XSD::XSDIDREFS
- XSD::XSDInt
- XSD::XSDInteger
- XSD::XSDLanguage
- XSD::XSDLong
- XSD::XSDNCName
- XSD::XSDNMTOKEN
- XSD::XSDNMTOKENS
- XSD::XSDName
- XSD::XSDNegativeInteger
- XSD::XSDNil
- XSD::XSDNonNegativeInteger
- XSD::XSDNonPositiveInteger
- XSD::XSDNormalizedString
- XSD::XSDPositiveInteger
- XSD::XSDQName
- XSD::XSDShort
- XSD::XSDString
- XSD::XSDTime
- XSD::XSDToken
- XSD::XSDUnsignedByte
- XSD::XSDUnsignedInt
- XSD::XSDUnsignedLong
- XSD::XSDUnsignedShort
- Object
- Object::SOAPMarshal
- WEBrick
- WEBrick::Log
- Enumerable
- Kernel

No matching classes.

# SOAP::Mapping::RubytypeFactory

### Constants

TYPE_ARRAY
TYPE_CLASS
TYPE_HASH
TYPE_MODULE
TYPE_RANGE
TYPE_REGEXP
TYPE_STRING
TYPE_STRUCT
TYPE_SYMBOL
TYPE_TIME

### Public Class Methods

new(config = {}) click to toggle source

    # File lib/soap/mapping/rubytypeFactory.rb, line 25
    def initialize(config = {})
      @config = config
      @allow_untyped_struct = @config.key?(:allow_untyped_struct) ?
        @config[:allow_untyped_struct] : true
      @allow_original_mapping = @config.key?(:allow_original_mapping) ?
        @config[:allow_original_mapping] : false
      @string_factory = StringFactory_.new(true)
      @basetype_factory = BasetypeFactory_.new(true)
      @datetime_factory = DateTimeFactory_.new(true)
      @array_factory = ArrayFactory_.new(true)
      @hash_factory = HashFactory_.new(true)
    end

### Public Instance Methods

obj2soap(soap_class, obj, info, map) click to toggle source

    # File lib/soap/mapping/rubytypeFactory.rb, line 38
    def obj2soap(soap_class, obj, info, map)
      param = nil
      case obj
      when ::String
        unless @allow_original_mapping
          return nil
        end
        param = @string_factory.obj2soap(SOAPString, obj, info, map)
        if obj.class != String
          param.extraattr[RubyTypeName] = obj.class.name
        end
        addiv2soapattr(param, obj, map)
      when ::Time
        unless @allow_original_mapping
          return nil
        end
        param = @datetime_factory.obj2soap(SOAPDateTime, obj, info, map)
        if obj.class != Time
          param.extraattr[RubyTypeName] = obj.class.name
        end
        addiv2soapattr(param, obj, map)
      when ::Array
        unless @allow_original_mapping
          return nil
        end
        param = @array_factory.obj2soap(nil, obj, info, map)
        if obj.class != Array
          param.extraattr[RubyTypeName] = obj.class.name
        end
        addiv2soapattr(param, obj, map)
      when ::NilClass
        unless @allow_original_mapping
          return nil
        end
        param = @basetype_factory.obj2soap(SOAPNil, obj, info, map)
        addiv2soapattr(param, obj, map)
      when ::FalseClass, ::TrueClass
        unless @allow_original_mapping
          return nil
        end
        param = @basetype_factory.obj2soap(SOAPBoolean, obj, info, map)
        addiv2soapattr(param, obj, map)
      when ::Integer
        unless @allow_original_mapping
          return nil
        end
        param = @basetype_factory.obj2soap(SOAPInt, obj, info, map)
        param ||= @basetype_factory.obj2soap(SOAPInteger, obj, info, map)
        param ||= @basetype_factory.obj2soap(SOAPDecimal, obj, info, map)
        addiv2soapattr(param, obj, map)
      when ::Float
        unless @allow_original_mapping
          return nil
        end
        param = @basetype_factory.obj2soap(SOAPDouble, obj, info, map)
        if obj.class != Float
          param.extraattr[RubyTypeName] = obj.class.name
        end
        addiv2soapattr(param, obj, map)
      when ::Hash
        unless @allow_original_mapping
          return nil
        end
        if obj.respond_to?(:default_proc) && obj.default_proc
          raise TypeError.new("cannot dump hash with default proc")
        end
        param = SOAPStruct.new(TYPE_HASH)
        mark_marshalled_obj(obj, param)
        if obj.class != Hash
          param.extraattr[RubyTypeName] = obj.class.name
        end
        obj.each do |key, value|
          elem = SOAPStruct.new # Undefined type.
          elem.add("key", Mapping._obj2soap(key, map))
          elem.add("value", Mapping._obj2soap(value, map))
          param.add("item", elem)
        end
        param.add('default', Mapping._obj2soap(obj.default, map))
        addiv2soapattr(param, obj, map)
      when ::Regexp
        unless @allow_original_mapping
          return nil
        end
        param = SOAPStruct.new(TYPE_REGEXP)
        mark_marshalled_obj(obj, param)
        if obj.class != Regexp
          param.extraattr[RubyTypeName] = obj.class.name
        end
        param.add('source', SOAPBase64.new(obj.source))
        if obj.respond_to?('options')
          # Regexp#options is from Ruby/1.7
          options = obj.options
        else
          options = 0
          obj.inspect.sub(/^.*\//, '').each_byte do |c|
            options += case c
              when ii
                1
              when xx
                2
              when mm
                4
              when nn
                16
              when ee
                32
              when ss
                48
              when uu
                64
              end
          end
        end
        param.add('options', SOAPInt.new(options))
        addiv2soapattr(param, obj, map)
      when ::Range
        unless @allow_original_mapping
          return nil
        end
        param = SOAPStruct.new(TYPE_RANGE)
        mark_marshalled_obj(obj, param)
        if obj.class != Range
          param.extraattr[RubyTypeName] = obj.class.name
        end
        param.add('begin', Mapping._obj2soap(obj.begin, map))
        param.add('end', Mapping._obj2soap(obj.end, map))
        param.add('exclude_end', SOAP::SOAPBoolean.new(obj.exclude_end?))
        addiv2soapattr(param, obj, map)
      when ::Class
        unless @allow_original_mapping
          return nil
        end
        if obj.to_s[0] == ##
          raise TypeError.new("can't dump anonymous class #{obj}")
        end
        param = SOAPStruct.new(TYPE_CLASS)
        mark_marshalled_obj(obj, param)
        param.add('name', SOAPString.new(obj.name))
        addiv2soapattr(param, obj, map)
      when ::Module
        unless @allow_original_mapping
          return nil
        end
        if obj.to_s[0] == ##
          raise TypeError.new("can't dump anonymous module #{obj}")
        end
        param = SOAPStruct.new(TYPE_MODULE)
        mark_marshalled_obj(obj, param)
        param.add('name', SOAPString.new(obj.name))
        addiv2soapattr(param, obj, map)
      when ::Symbol
        unless @allow_original_mapping
          return nil
        end
        param = SOAPStruct.new(TYPE_SYMBOL)
        mark_marshalled_obj(obj, param)
        param.add('id', SOAPString.new(obj.id2name))
        addiv2soapattr(param, obj, map)
      when ::Struct
        unless @allow_original_mapping
          # treat it as an user defined class. [ruby-talk:104980]
          #param = unknownobj2soap(soap_class, obj, info, map)
          param = SOAPStruct.new(XSD::AnyTypeName)
          mark_marshalled_obj(obj, param)
          obj.members.each do |member|
            param.add(Mapping.name2elename(member),
              Mapping._obj2soap(obj[member], map))
          end
        else
          param = SOAPStruct.new(TYPE_STRUCT)
          mark_marshalled_obj(obj, param)
          param.add('type', ele_type = SOAPString.new(obj.class.to_s))
          ele_member = SOAPStruct.new
          obj.members.each do |member|
            ele_member.add(Mapping.name2elename(member),
              Mapping._obj2soap(obj[member], map))
          end
          param.add('member', ele_member)
          addiv2soapattr(param, obj, map)
        end
      when ::IO, ::Binding, ::Continuation, ::Data, ::Dir, ::File::Stat,
          ::MatchData, Method, ::Proc, ::Thread, ::ThreadGroup
          # from 1.8: Process::Status, UnboundMethod
        return nil
      when ::SOAP::Mapping::Object
        param = SOAPStruct.new(XSD::AnyTypeName)
        mark_marshalled_obj(obj, param)
        obj.__xmlele.each do |key, value|
          param.add(key.name, Mapping._obj2soap(value, map))
        end
        obj.__xmlattr.each do |key, value|
          param.extraattr[key] = value
        end
      when ::Exception
        typestr = Mapping.name2elename(obj.class.to_s)
        param = SOAPStruct.new(XSD::QName.new(RubyTypeNamespace, typestr))
        mark_marshalled_obj(obj, param)
        param.add('message', Mapping._obj2soap(obj.message, map))
        param.add('backtrace', Mapping._obj2soap(obj.backtrace, map))
        addiv2soapattr(param, obj, map)
      else
        param = unknownobj2soap(soap_class, obj, info, map)
      end
      param
    end

soap2obj(obj_class, node, info, map) click to toggle source

    # File lib/soap/mapping/rubytypeFactory.rb, line 244
    def soap2obj(obj_class, node, info, map)
      rubytype = node.extraattr[RubyTypeName]
      if rubytype or node.type.namespace == RubyTypeNamespace
        rubytype2obj(node, info, map, rubytype)
      elsif node.type == XSD::AnyTypeName or node.type == XSD::AnySimpleTypeName
        anytype2obj(node, info, map)
      else
        unknowntype2obj(node, info, map)
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.