X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/3bbeb70642a9403e0d1acce9fc9f780065206eab..db1e02adb5f8eea1fc47bfe4e7b116359d92eaa2:/app/models/old_way.rb diff --git a/app/models/old_way.rb b/app/models/old_way.rb index 3f978d3d4..1aac4ebff 100644 --- a/app/models/old_way.rb +++ b/app/models/old_way.rb @@ -8,7 +8,58 @@ class OldWay < ActiveRecord::Base old_way.user_id = way.user_id old_way.timestamp = way.timestamp old_way.id = way.id + old_way.segs = way.segs + old_way.tags = way.tags return old_way end + def save + t = Time.now + self.timestamp = t + self.save + + WayTag.delete_all(['id = ?', self.id]) + + self.tags.each do |k,v| + tag = WayTag.new + tag.k = k + tag.v = v + tag.id = self.id + tag.save + end + + WaySegment.delete_all(['id = ?', self.id]) + + i = 0 + self.segs.each do |n| + seg = WaySegment.new + seg.id = self.id + seg.segment_id = n + seg.sequence_id = i + seg.save + i += 1 + end + + old_way = OldWay.from_way(self) + old_way.save + end + + def segs + @segs = Array.new unless @segs + @segs + end + + def tags + @tags = Hash.new unless @tags + @tags + end + + def segs=(s) + @segs = s + end + + def tags=(t) + @tags = t + end + end