diff options
| author | Alban Peignier | 2017-12-17 22:14:17 +0100 | 
|---|---|---|
| committer | Alban Peignier | 2018-01-05 10:23:29 +0100 | 
| commit | 78c2b9deaefa4aa5c0ac5173055cb2cacd3d27c1 (patch) | |
| tree | 7c61327521783f9a921e595319f2d4862b0342cf /app/models/referential.rb | |
| parent | f90488de1f657abf24026231485c87d3e42ee11d (diff) | |
| download | chouette-core-78c2b9deaefa4aa5c0ac5173055cb2cacd3d27c1.tar.bz2 | |
First try for route/stop_point and journey_pattern merge. RefsĀ #5299
Diffstat (limited to 'app/models/referential.rb')
| -rw-r--r-- | app/models/referential.rb | 30 | 
1 files changed, 27 insertions, 3 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index 4fa353a37..8087ea61e 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -144,6 +144,18 @@ class Referential < ActiveRecord::Base      Chouette::PurchaseWindow.all    end +  def routes +    Chouette::Route.all +  end + +  def journey_patterns +    Chouette::JourneyPattern.all +  end + +  def stop_points +    Chouette::StopPoint.all +  end +    before_validation :define_default_attributes    def define_default_attributes @@ -151,10 +163,22 @@ class Referential < ActiveRecord::Base      self.objectid_format ||= workbench.objectid_format if workbench    end -  def switch +  def switch(&block)      raise "Referential not created" if new_record? -    Apartment::Tenant.switch!(slug) -    self + +    unless block_given? +      Rails.logger.debug "Referential switch to #{slug}" +      Apartment::Tenant.switch! slug +      self +    else +      result = nil +      Apartment::Tenant.switch slug do +        Rails.logger.debug "Referential switch to #{slug}" +        result = yield +      end +      Rails.logger.debug "Referential back" +      result +    end    end    def self.new_from(from, functional_scope) | 
