aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette/objectid
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/chouette/objectid')
-rw-r--r--app/models/chouette/objectid/netex.rb13
-rw-r--r--app/models/chouette/objectid/stif_netex.rb2
2 files changed, 6 insertions, 9 deletions
diff --git a/app/models/chouette/objectid/netex.rb b/app/models/chouette/objectid/netex.rb
index 254ce6c6e..0013de7c8 100644
--- a/app/models/chouette/objectid/netex.rb
+++ b/app/models/chouette/objectid/netex.rb
@@ -5,12 +5,13 @@ module Chouette
attr_accessor :provider_id, :object_type, :local_id, :creation_id
validates_presence_of :provider_id, :object_type, :local_id, :creation_id
+ validate :must_respect_format
def initialize(**attributes)
- @provider_id ||= 'chouette'
+ @provider_id ||= (attributes[:provider_id] ||= 'chouette')
@object_type = attributes[:object_type]
@local_id = attributes[:local_id]
- @creation_id ||= 'LOC'
+ @creation_id = (attributes[:creation_id] ||= 'LOC')
end
@@format = /^([A-Za-z_-]+):([A-Za-z]+):([0-9A-Za-z_-]+):([A-Za-z]+)$/
@@ -20,12 +21,8 @@ module Chouette
"#{self.provider_id}:#{self.object_type}:#{self.local_id}:#{self.creation_id}"
end
- def parts
- self.to_s.match(format).try(:captures)
- end
-
- def valid?
- parts.present?
+ def must_respect_format
+ self.to_s.match(format)
end
def short_id
diff --git a/app/models/chouette/objectid/stif_netex.rb b/app/models/chouette/objectid/stif_netex.rb
index e9d40a00f..4894daac7 100644
--- a/app/models/chouette/objectid/stif_netex.rb
+++ b/app/models/chouette/objectid/stif_netex.rb
@@ -3,7 +3,7 @@ module Chouette
class StifNetex < Chouette::Objectid::Netex
def initialize(**attributes)
- @provider_id = 'stif'
+ @provider_id = (attributes[:provider_id] ||= 'stif')
super
end