diff options
| author | cedricnjanga | 2017-11-21 15:32:22 +0100 | 
|---|---|---|
| committer | cedricnjanga | 2017-11-22 14:03:51 +0100 | 
| commit | 9304f16e56c219fd63fa12b7d42a7cbf16b2914a (patch) | |
| tree | 0a3d2dddcde40892aa68c8d14e3bd0e2ca7cb24b /app/models/chouette/access_link.rb | |
| parent | 40a5b7409d5214dd8361937c0c9d4726acb53222 (diff) | |
| download | chouette-core-9304f16e56c219fd63fa12b7d42a7cbf16b2914a.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/access_link.rb')
| -rw-r--r-- | app/models/chouette/access_link.rb | 89 | 
1 files changed, 45 insertions, 44 deletions
| diff --git a/app/models/chouette/access_link.rb b/app/models/chouette/access_link.rb index 5e44704fd..46fbcb631 100644 --- a/app/models/chouette/access_link.rb +++ b/app/models/chouette/access_link.rb @@ -4,62 +4,63 @@ module Chouette      # FIXME http://jira.codehaus.org/browse/JRUBY-6358      self.primary_key = "id" -  attr_accessor :access_link_type, :link_orientation_type, :link_key +    attr_accessor :access_link_type, :link_orientation_type, :link_key -  belongs_to :access_point, :class_name => 'Chouette::AccessPoint' -  belongs_to :stop_area, :class_name => 'Chouette::StopArea' +    belongs_to :access_point, :class_name => 'Chouette::AccessPoint' +    belongs_to :stop_area, :class_name => 'Chouette::StopArea' -  validates_presence_of :name -  validates_presence_of :link_orientation +    validates_presence_of :name +    validates_presence_of :link_orientation -  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 access_link_type -    link_type && Chouette::ConnectionLinkType.new(link_type.underscore) -  end +    def access_link_type +      link_type && Chouette::ConnectionLinkType.new(link_type.underscore) +    end -  def access_link_type=(access_link_type) -    self.link_type = (access_link_type ? access_link_type.camelcase : nil) -  end +    def access_link_type=(access_link_type) +      self.link_type = (access_link_type ? access_link_type.camelcase : nil) +    end -  @@access_link_types = nil -  def self.access_link_types -    @@access_link_types ||= Chouette::ConnectionLinkType.all -  end +    @@access_link_types = nil +    def self.access_link_types +      @@access_link_types ||= Chouette::ConnectionLinkType.all +    end -  def link_orientation_type -    link_orientation && Chouette::LinkOrientationType.new(link_orientation.underscore) -  end +    def link_orientation_type +      link_orientation && Chouette::LinkOrientationType.new(link_orientation.underscore) +    end -  def link_orientation_type=(link_orientation_type) -    self.link_orientation = (link_orientation_type ? link_orientation_type.camelcase : nil) -  end +    def link_orientation_type=(link_orientation_type) +      self.link_orientation = (link_orientation_type ? link_orientation_type.camelcase : nil) +    end -  @@link_orientation_types = nil -  def self.link_orientation_types -    @@link_orientation_types ||= Chouette::LinkOrientationType.all -  end +    @@link_orientation_types = nil +    def self.link_orientation_types +      @@link_orientation_types ||= Chouette::LinkOrientationType.all +    end -  def geometry -    GeoRuby::SimpleFeatures::LineString.from_points( [ access_point.geometry, stop_area.geometry], 4326) if access_point.geometry and stop_area.geometry -  end +    def geometry +      GeoRuby::SimpleFeatures::LineString.from_points( [ access_point.geometry, stop_area.geometry], 4326) if access_point.geometry and stop_area.geometry +    end -  def link_key -    Chouette::AccessLink.build_link_key(access_point,stop_area,link_orientation_type) -  end -   -  def self.build_link_key(access_point,stop_area,link_orientation_type) -    if link_orientation_type == "access_point_to_stop_area" -      "A_#{access_point.id}-S_#{stop_area.id}" -    else   -      "S_#{stop_area.id}-A_#{access_point.id}" +    def link_key +      Chouette::AccessLink.build_link_key(access_point,stop_area,link_orientation_type) +    end +     +    def self.build_link_key(access_point,stop_area,link_orientation_type) +      if link_orientation_type == "access_point_to_stop_area" +        "A_#{access_point.id}-S_#{stop_area.id}" +      else   +        "S_#{stop_area.id}-A_#{access_point.id}" +      end      end -  end -  def geometry_presenter -    Chouette::Geometry::AccessLinkPresenter.new self +    def geometry_presenter +      Chouette::Geometry::AccessLinkPresenter.new self +    end    end  end
\ No newline at end of file | 
