Class: SOAP::Mapping::HashFactory_
- Defined in:
- lib/soap/mapping/factory.rb
Instance Method Summary collapse
-
#initialize(allow_original_mapping = false) ⇒ HashFactory_
constructor
A new instance of HashFactory_.
- #obj2soap(soap_class, obj, info, map) ⇒ Object
- #soap2obj(obj_class, node, info, map) ⇒ Object
Methods inherited from Factory
Methods included from TraverseSupport
#mark_marshalled_obj, #mark_unmarshalled_obj
Constructor Details
#initialize(allow_original_mapping = false) ⇒ HashFactory_
Returns a new instance of HashFactory_.
338 339 340 341 |
# File 'lib/soap/mapping/factory.rb', line 338 def initialize(allow_original_mapping = false) super() @allow_original_mapping = allow_original_mapping end |
Instance Method Details
#obj2soap(soap_class, obj, info, map) ⇒ Object
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/soap/mapping/factory.rb', line 343 def obj2soap(soap_class, obj, info, map) if !@allow_original_mapping and !obj.instance_variables.empty? return nil end if !obj.default.nil? or (obj.respond_to?(:default_proc) and obj.default_proc) return nil end soap_obj = SOAPStruct.new(MapQName) mark_marshalled_obj(obj, soap_obj) obj.each do |key, value| elem = SOAPStruct.new elem.add("key", Mapping._obj2soap(key, map)) elem.add("value", Mapping._obj2soap(value, map)) # ApacheAxis allows only 'item' here. soap_obj.add("item", elem) end soap_obj end |
#soap2obj(obj_class, node, info, map) ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/soap/mapping/factory.rb', line 363 def soap2obj(obj_class, node, info, map) unless node.type == MapQName return false end if node.class == SOAPStruct and node.key?('default') return false end obj = Mapping.create_empty_object(obj_class) mark_unmarshalled_obj(node, obj) if node.class == SOAPStruct node.each do |key, value| obj[Mapping._soap2obj(value['key'], map)] = Mapping._soap2obj(value['value'], map) end else node.each do |value| obj[Mapping._soap2obj(value['key'], map)] = Mapping._soap2obj(value['value'], map) end end return true, obj end |