end
def tags
- unless @tags
- @tags = {}
- self.node_tags.each do |tag|
- @tags[tag.k] = tag.v
- end
- end
- @tags
+ @tags ||= Hash[self.node_tags.collect { |t| [t.k, t.v] }]
end
def tags=(t)
end
def tags
- unless @tags
- @tags = Hash.new
- self.old_tags.each do |tag|
- @tags[tag.k] = tag.v
- end
- end
- @tags = Hash.new unless @tags
- @tags
+ @tags ||= Hash[self.old_tags.collect { |t| [t.k, t.v] }]
end
def tags=(t)
end
def members
- unless @members
- @members = Array.new
- self.old_members.order(:sequence_id).each do |m|
- @members += [[m.member_type,m.member_id,m.member_role]]
- end
+ @members ||= self.old_members.collect do |member|
+ [member.member_type, member.member_id, member.member_role]
end
- @members
end
def tags
- unless @tags
- @tags = Hash.new
- self.old_tags.each do |tag|
- @tags[tag.k] = tag.v
- end
- end
- @tags = Hash.new unless @tags
- @tags
+ @tags ||= Hash[self.old_tags.collect { |t| [t.k, t.v] }]
end
def members=(s)
end
def nds
- unless @nds
- @nds = Array.new
- self.old_nodes.order(:sequence_id).each do |nd|
- @nds += [nd.node_id]
- end
- end
- @nds
+ @nds ||= self.old_nodes.order(:sequence_id).collect { |n| n.node_id }
end
def tags
- unless @tags
- @tags = Hash.new
- self.old_tags.each do |tag|
- @tags[tag.k] = tag.v
- end
- end
- @tags = Hash.new unless @tags
- @tags
+ @tags ||= Hash[self.old_tags.collect { |t| [t.k, t.v] }]
end
def nds=(s)
end
def tags
- unless @tags
- @tags = Hash.new
- self.relation_tags.each do |tag|
- @tags[tag.k] = tag.v
- end
- end
- @tags
+ @tags ||= Hash[self.relation_tags.collect { |t| [t.k, t.v] }]
end
def members=(m)
validates_associated :changeset
scope :visible, -> { where(:visible => true) }
- scope :invisible, -> { where(:visible => false) }
+ scope :invisible, -> { where(:visible => false) }
# Read in xml as text and return it's Way object representation
def self.from_xml(xml, create=false)
end
def nds
- unless @nds
- @nds = Array.new
- self.way_nodes.each do |nd|
- @nds += [nd.node_id]
- end
- end
- @nds
+ @nds ||= self.way_nodes.collect { |n| n.node_id }
end
def tags
- unless @tags
- @tags = {}
- self.way_tags.each do |tag|
- @tags[tag.k] = tag.v
- end
- end
- @tags
+ @tags ||= Hash[self.way_tags.collect { |t| [t.k, t.v] }]
end
def nds=(s)