blob: 0b122c91bc1df250cf98a3e8a2dfdd85f5cafa53 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  | 
class Chouette::ObjectId < String
  def valid?
    parts.present?
  end
  alias_method :objectid?, :valid?
  @@format = /^([0-9A-Za-z_]+):([A-Za-z]+):([0-9A-Za-z_-]+)$/
  cattr_reader :format
  def parts
    match(format).try(:captures)
  end
  def system_id
    parts.try(:first)
  end
  def object_type
    parts.try(:second)
  end
  def local_id
    parts.try(:third)
  end
  def self.create(system_id, object_type, local_id)
    new [system_id, object_type, local_id].join(":")
  end
  def self.new(string)
    string ||= ""
    self === string ? string : super
  end
end
  |