Class: XSD::Mapping::Mapper
Constant Summary collapse
- MAPPING_OPT =
{ :default_encodingstyle => SOAP::LiteralNamespace, :generate_explicit_type => false, :root_type_hint => true }.freeze
Instance Method Summary collapse
-
#initialize(registry) ⇒ Mapper
constructor
A new instance of Mapper.
- #obj2xml(obj, elename = nil, io = nil) ⇒ Object
- #xml2obj(stream, klass = nil) ⇒ Object
Constructor Details
#initialize(registry) ⇒ Mapper
Returns a new instance of Mapper.
37 38 39 |
# File 'lib/xsd/mapping.rb', line 37 def initialize(registry) @registry = registry end |
Instance Method Details
#obj2xml(obj, elename = nil, io = nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/xsd/mapping.rb', line 41 def obj2xml(obj, elename = nil, io = nil) opt = MAPPING_OPT.dup unless elename if definition = @registry.elename_schema_definition_from_class(obj.class) elename = definition.elename opt[:root_type_hint] = false end end elename = SOAP::Mapping.to_qname(elename) if elename soap = SOAP::Mapping.obj2soap(obj, @registry, elename, opt) if soap.elename.nil? or soap.elename == XSD::QName::EMPTY soap.elename = XSD::QName.new(nil, SOAP::Mapping.name2elename(obj.class.to_s)) end generator = SOAP::Generator.new(opt) generator.generate(soap, io) end |