From b4be5596f5553c29831a01bd3f8cce14c5435156 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 30 Aug 2017 11:40:54 +0100 Subject: [PATCH] Rename xml processing methods with an update_ prefix They behave differently from the other from_xml methods on other models. --- app/controllers/trace_controller.rb | 2 +- app/models/trace.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/trace_controller.rb b/app/controllers/trace_controller.rb index 4e10a6c0c..41c488e0f 100644 --- a/app/controllers/trace_controller.rb +++ b/app/controllers/trace_controller.rb @@ -263,7 +263,7 @@ class TraceController < ApplicationController trace = Trace.visible.find(params[:id]) if trace.user == current_user - trace.from_xml(request.raw_post) + trace.update_from_xml(request.raw_post) trace.save! head :ok diff --git a/app/models/trace.rb b/app/models/trace.rb index b7b96c65e..160060a6d 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -172,12 +172,12 @@ class Trace < ActiveRecord::Base el1 end - def from_xml(xml, create = false) + def update_from_xml(xml, create = false) p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR) doc = p.parse doc.find("//osm/gpx_file").each do |pt| - return from_xml_node(pt, create) + return update_from_xml_node(pt, create) end raise OSM::APIBadXMLError.new("trace", xml, "XML doesn't contain an osm/gpx_file element.") @@ -185,7 +185,7 @@ class Trace < ActiveRecord::Base raise OSM::APIBadXMLError.new("trace", xml, ex.message) end - def from_xml_node(pt, create = false) + def update_from_xml_node(pt, create = false) raise OSM::APIBadXMLError.new("trace", pt, "visibility missing") if pt["visibility"].nil? self.visibility = pt["visibility"] -- 2.43.2