Update to_ar to use symbolized keys

GSoC/Meterpreter_Web_Console
James Barnett 2018-12-12 11:47:14 -06:00
parent 260bfdc071
commit bcfe434d1e
No known key found for this signature in database
GPG Key ID: 647983861A4EC5EA
1 changed files with 5 additions and 3 deletions

View File

@ -49,7 +49,7 @@ module ResponseDataHelper
begin
body = process_response(response_wrapper)
if !body.nil? && !body.empty?
parsed_body = JSON.parse(body).symbolize_keys
parsed_body = JSON.parse(body, symbolize_names: true)
data = Array.wrap(parsed_body[:data])
rv = []
data.each do |json_object|
@ -107,7 +107,9 @@ module ResponseDataHelper
reflection
end
data.except(*obj.attributes.keys).each do |k, v|
obj_attribute_names = obj.attributes.transform_keys { |k| k.to_sym }.keys
data.except(*obj_attribute_names).each do |k, v|
association = klass.reflect_on_association(k)
next unless association
@ -133,7 +135,7 @@ module ResponseDataHelper
end
end
end
obj.assign_attributes(data.slice(*obj.attributes.keys))
obj.assign_attributes(data.slice(*obj_attribute_names))
obj.instance_eval do
# prevent save