source: subversion/sites/rails_port/app/models/old_segment.rb @ 3148

Last change on this file since 3148 was 2417, checked in by steve, 13 years ago

API returns user info if public

File size: 828 bytes
Line 
1class OldSegment < ActiveRecord::Base
2  set_table_name 'segments'
3
4  belongs_to :user
5
6  def self.from_segment(segment)
7    old_segment = OldSegment.new
8    old_segment.node_a = segment.node_a
9    old_segment.node_b = segment.node_b
10    old_segment.visible = segment.visible
11    old_segment.tags = segment.tags
12    old_segment.timestamp = segment.timestamp
13    old_segment.user_id = segment.user_id
14    old_segment.id = segment.id
15    return old_segment
16  end
17
18  def to_xml_node
19    el1 = XML::Node.new 'segment'
20    el1['id'] = self.id.to_s
21    el1['from'] = self.node_a.to_s
22    el1['to'] = self.node_b.to_s
23    el1['user'] = self.user.display_name if self.user.data_public?
24    Segment.split_tags(el1, self.tags)
25    el1['visible'] = self.visible.to_s
26    el1['timestamp'] = self.timestamp.xmlschema
27    return el1
28  end
29end
Note: See TracBrowser for help on using the repository browser.