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_.
304 305 306 307 |
# File 'lib/soap/mapping/factory.rb', line 304 def initialize(allow_original_mapping = false) super() @allow_original_mapping = allow_original_mapping end |
Instance Method Details
#obj2soap(soap_class, obj, info, map) ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'lib/soap/mapping/factory.rb', line 309 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
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/soap/mapping/factory.rb', line 329 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 |