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



206
207
208
209
# File 'lib/soap/mapping/factory.rb', line 206

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.



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/soap/mapping/factory.rb', line 213

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



231
232
233
234
235
236
237
238
# File 'lib/soap/mapping/factory.rb', line 231

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