aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette/network.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/chouette/network.rb')
-rw-r--r--app/models/chouette/network.rb73
1 files changed, 37 insertions, 36 deletions
diff --git a/app/models/chouette/network.rb b/app/models/chouette/network.rb
index 8df205789..3f07ebe0c 100644
--- a/app/models/chouette/network.rb
+++ b/app/models/chouette/network.rb
@@ -1,49 +1,50 @@
-class Chouette::Network < Chouette::ActiveRecord
- include StifCodifligneAttributesSupport
- include NetworkRestrictions
- include LineReferentialSupport
- # FIXME http://jira.codehaus.org/browse/JRUBY-6358
- self.primary_key = "id"
+module Chouette
+ class Network < Chouette::ActiveRecord
+ include NetworkRestrictions
+ include LineReferentialSupport
+ include ObjectidSupport
+ # FIXME http://jira.codehaus.org/browse/JRUBY-6358
+ self.primary_key = "id"
- has_many :lines
+ has_many :lines
- attr_accessor :source_type_name
+ attr_accessor :source_type_name
- validates_format_of :registration_number, :with => %r{\A[0-9A-Za-z_-]+\Z}, :allow_nil => true, :allow_blank => true
- validates_presence_of :name
+ validates_format_of :registration_number, :with => %r{\A[0-9A-Za-z_-]+\Z}, :allow_nil => true, :allow_blank => true
+ validates_presence_of :name
- def self.object_id_key
- "PTNetwork"
- end
-
- def self.nullable_attributes
- [:source_name, :source_type, :source_identifier, :comment]
- end
+ def self.object_id_key
+ "PTNetwork"
+ end
- def commercial_stop_areas
- Chouette::StopArea.joins(:children => [:stop_points => [:route => [:line => :network] ] ]).where(:networks => {:id => self.id}).uniq
- end
+ def self.nullable_attributes
+ [:source_name, :source_type, :source_identifier, :comment]
+ end
- def stop_areas
- Chouette::StopArea.joins(:stop_points => [:route => [:line => :network] ]).where(:networks => {:id => self.id})
- end
+ def commercial_stop_areas
+ Chouette::StopArea.joins(:children => [:stop_points => [:route => [:line => :network] ] ]).where(:networks => {:id => self.id}).uniq
+ end
- def source_type_name
- # return nil if source_type is nil
- source_type && Chouette::SourceType.new( source_type.underscore)
- end
+ def stop_areas
+ Chouette::StopArea.joins(:stop_points => [:route => [:line => :network] ]).where(:networks => {:id => self.id})
+ end
- def source_type_name=(source_type_name)
- self.source_type = (source_type_name ? source_type_name.camelcase : nil)
- end
+ def source_type_name
+ # return nil if source_type is nil
+ source_type && Chouette::SourceType.new( source_type.underscore)
+ end
- @@source_type_names = nil
- def self.source_type_names
- @@source_type_names ||= Chouette::SourceType.all.select do |source_type_name|
- source_type_name.to_i > 0
+ def source_type_name=(source_type_name)
+ self.source_type = (source_type_name ? source_type_name.camelcase : nil)
end
- end
+ @@source_type_names = nil
+ def self.source_type_names
+ @@source_type_names ||= Chouette::SourceType.all.select do |source_type_name|
+ source_type_name.to_i > 0
+ end
+ end
-end
+ end
+end \ No newline at end of file