Class: SOAP::Mapping::ArrayFactory_

Inherits:
Factory show all
Defined in:
lib/soap/mapping/factory.rb

Instance Method Summary collapse

Methods inherited from Factory

#setiv2obj, #setiv2soap

Methods included from TraverseSupport

#mark_marshalled_obj, #mark_unmarshalled_obj

Constructor Details

#initialize(allow_original_mapping = false) ⇒ ArrayFactory_

Returns a new instance of ArrayFactory_



238
239
240
241
# File 'lib/soap/mapping/factory.rb', line 238

def initialize(allow_original_mapping = false)
  super()
  @allow_original_mapping = allow_original_mapping
end

Instance Method Details

#obj2soap(soap_class, obj, info, map) ⇒ Object

[1], [2]

is converted to Array of Array, not 2-D Array.

To create M-D Array, you must call Mapping.ary2md.



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/soap/mapping/factory.rb', line 245

def obj2soap(soap_class, obj, info, map)
  if !@allow_original_mapping and !obj.instance_variables.empty?
    return nil
  end
  arytype = Mapping.obj2element(obj)
  if arytype.name
    arytype.namespace ||= RubyTypeNamespace
  else
    arytype = XSD::AnyTypeName
  end
  soap_obj = SOAPArray.new(ValueArrayName, 1, arytype)
  mark_marshalled_obj(obj, soap_obj)
  obj.each do |item|
    soap_obj.add(Mapping._obj2soap(item, map))
  end
  soap_obj
end

#soap2obj(obj_class, node, info, map) ⇒ Object



263
264
265
266
267
268
269
270
# File 'lib/soap/mapping/factory.rb', line 263

def soap2obj(obj_class, node, info, map)
  obj = Mapping.create_empty_object(obj_class)
  mark_unmarshalled_obj(node, obj)
  node.soap2array(obj) do |elem|
    elem ? Mapping._soap2obj(elem, map) : nil
  end
  return true, obj
end