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_.



222
223
224
225
# File 'lib/soap/mapping/factory.rb', line 222

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.



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/soap/mapping/factory.rb', line 229

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



247
248
249
250
251
252
253
254
# File 'lib/soap/mapping/factory.rb', line 247

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