Class: ActionWebService::Protocol::Soap::SoapActiveRecordStructFactory

Inherits:
SOAP::Mapping::Factory
  • Object
show all
Defined in:
lib/action_web_service/protocol/soap_protocol/marshaler.rb

Instance Method Summary collapse

Instance Method Details

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



178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/action_web_service/protocol/soap_protocol/marshaler.rb', line 178

def obj2soap(soap_class, obj, info, map)
  unless obj.is_a?(ActiveRecord::Base)
    return nil
  end
  soap_obj = soap_class.new(obj.class.instance_variable_get('@qname'))
  obj.class.columns.each do |column|
    key = column.name.to_s
    value = obj.send(key)
    soap_obj[key] = SOAP::Mapping._obj2soap(value, map)
  end
  soap_obj
end

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



191
192
193
194
195
196
197
198
199
200
201
# File 'lib/action_web_service/protocol/soap_protocol/marshaler.rb', line 191

def soap2obj(obj_class, node, info, map)
  unless node.type == obj_class.instance_variable_get('@qname')
    return false
  end
  obj = obj_class.new
  node.each do |key, value|
    obj[key] = value.data
  end
  obj.instance_variable_set('@new_record', false)
  return true, obj
end