diff options
| author | cedricnjanga | 2017-11-21 15:32:22 +0100 | 
|---|---|---|
| committer | cedricnjanga | 2017-11-21 15:32:22 +0100 | 
| commit | 763010ced3202c99f705562a373861f926aad9a1 (patch) | |
| tree | a316366c92fcf9c88aa8d08ff34e0b737196d618 /app/models/chouette/connection_link.rb | |
| parent | 80bfa87237b78e426e4362a503fe4d72e130beb5 (diff) | |
| download | chouette-core-763010ced3202c99f705562a373861f926aad9a1.tar.bz2 | |
Change the way we name classes
We now always use modules for namespaces
=> same structure for models, decorators, policies...
Diffstat (limited to 'app/models/chouette/connection_link.rb')
| -rw-r--r-- | app/models/chouette/connection_link.rb | 75 | 
1 files changed, 38 insertions, 37 deletions
| diff --git a/app/models/chouette/connection_link.rb b/app/models/chouette/connection_link.rb index b3d999152..d19b53974 100644 --- a/app/models/chouette/connection_link.rb +++ b/app/models/chouette/connection_link.rb @@ -1,49 +1,50 @@ -class Chouette::ConnectionLink < Chouette::TridentActiveRecord -  include ObjectidSupport -  include ConnectionLinkRestrictions -  # FIXME http://jira.codehaus.org/browse/JRUBY-6358 -  self.primary_key = "id" +module Chouette +  class ConnectionLink < Chouette::TridentActiveRecord +    include ObjectidSupport +    include ConnectionLinkRestrictions +    # FIXME http://jira.codehaus.org/browse/JRUBY-6358 +    self.primary_key = "id" -  attr_accessor :connection_link_type +    attr_accessor :connection_link_type -  belongs_to :departure, :class_name => 'Chouette::StopArea' -  belongs_to :arrival, :class_name => 'Chouette::StopArea' +    belongs_to :departure, :class_name => 'Chouette::StopArea' +    belongs_to :arrival, :class_name => 'Chouette::StopArea' -  validates_presence_of :name +    validates_presence_of :name -  def self.nullable_attributes -    [:link_distance, :default_duration, :frequent_traveller_duration, :occasional_traveller_duration, -      :mobility_restricted_traveller_duration, :link_type] -  end +    def self.nullable_attributes +      [:link_distance, :default_duration, :frequent_traveller_duration, :occasional_traveller_duration, +        :mobility_restricted_traveller_duration, :link_type] +    end -  def connection_link_type -    link_type && Chouette::ConnectionLinkType.new( link_type.underscore) -  end +    def connection_link_type +      link_type && Chouette::ConnectionLinkType.new( link_type.underscore) +    end -  def connection_link_type=(connection_link_type) -    self.link_type = (connection_link_type ? connection_link_type.camelcase : nil) -  end - -  @@connection_link_types = nil -  def self.connection_link_types -    @@connection_link_types ||= Chouette::ConnectionLinkType.all -  end +    def connection_link_type=(connection_link_type) +      self.link_type = (connection_link_type ? connection_link_type.camelcase : nil) +    end -  def possible_areas -    Chouette::StopArea.where("area_type != 'ITL'") -  end +    @@connection_link_types = nil +    def self.connection_link_types +      @@connection_link_types ||= Chouette::ConnectionLinkType.all +    end -  def stop_areas -    Chouette::StopArea.where(:id => [self.departure_id,self.arrival_id]) -  end +    def possible_areas +      Chouette::StopArea.where("area_type != 'ITL'") +    end -  def geometry -    GeoRuby::SimpleFeatures::LineString.from_points( [ departure.geometry, arrival.geometry], 4326) if departure.geometry and arrival.geometry -  end +    def stop_areas +      Chouette::StopArea.where(:id => [self.departure_id,self.arrival_id]) +    end -  def geometry_presenter -    Chouette::Geometry::ConnectionLinkPresenter.new self -  end +    def geometry +      GeoRuby::SimpleFeatures::LineString.from_points( [ departure.geometry, arrival.geometry], 4326) if departure.geometry and arrival.geometry +    end -end +    def geometry_presenter +      Chouette::Geometry::ConnectionLinkPresenter.new self +    end +  end +end
\ No newline at end of file | 
