13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/backframe/response/adapter/xml.rb', line 13
def render(collection, fields)
output = '<?xml version="1.0"?>'
output += "<records>"
collection.records.each do |item|
serialized = ActiveModelSerializers::SerializableResource.new(item).serializable_hash
output += "<record>"
fields.array.each do |field|
value = Backframe::Response::Record.get_value(serialized, field[:key])
output += "<#{field[:key]}>#{value}</#{field[:key]}>"
end
output += "</record>"
end
output += "</records>"
output
end
|