diff options
| author | Marc Florisson | 2014-12-23 10:35:29 +0100 | 
|---|---|---|
| committer | Marc Florisson | 2014-12-23 10:35:29 +0100 | 
| commit | b9f8295a08559abf1bd2bb5f1181e7e4f3de0a69 (patch) | |
| tree | e6741ff9e4a6efdaac59f8196bb9f09ca56332d9 | |
| parent | 3156f45338240b9e153028cfaf0e364a4d2d558a (diff) | |
| download | chouette-core-b9f8295a08559abf1bd2bb5f1181e7e4f3de0a69.tar.bz2 | |
fix after_initialization for ninoxe model
| -rw-r--r-- | app/models/referential.rb | 61 | ||||
| -rw-r--r-- | config/initializers/ninoxe_extension.rb | 44 | 
2 files changed, 61 insertions, 44 deletions
| diff --git a/app/models/referential.rb b/app/models/referential.rb index 5940b57ea..063e7436c 100644 --- a/app/models/referential.rb +++ b/app/models/referential.rb @@ -191,6 +191,67 @@ class Referential < ActiveRecord::Base      GeoRuby::SimpleFeatures::Geometry.from_ewkt(bounds.present? ? bounds : default_bounds ).envelope    end +  ## +  # In Development environment where cache_classes = false +  # each time a controller rb file is saved +  # ninoxe models are reloaded without after_initialize from config/initializers +  # so for development confort, it's better to keep here that after_initialize +Rails.application.config.after_initialize do + +  Chouette::TridentActiveRecord + +  class Chouette::TridentActiveRecord + +    # add referential relationship for objectid and localization functions +    def referential +      @referential ||= Referential.where(:slug => Apartment::Database.current_database).first! +    end + +    # override prefix for good prefix in objectid generation +    def prefix +      self.referential.prefix +    end + +  end + +  Chouette::TimeTable + +  class Chouette::TimeTable +    def presenter +      @presenter ||= ::TimeTablePresenter.new( self) +    end +  end + +  Chouette::VehicleJourney + +  class Chouette::VehicleJourney +    def presenter +      @presenter ||= ::VehicleJourneyPresenter.new( self) +    end +  end + +  Chouette::StopArea + +  class Chouette::StopArea + +    include  NinoxeExtension::ProjectionFields + +    # override default_position method to add referential envelope when no stoparea is positioned +    def default_position +      # for first StopArea ... the bounds is nil , set to referential center +      Chouette::StopArea.bounds ? Chouette::StopArea.bounds.center : self.referential.envelope.center +    end + + +  end + +  Chouette::AccessPoint + +  class Chouette::AccessPoint +    include  NinoxeExtension::ProjectionFields +  end + +end  end diff --git a/config/initializers/ninoxe_extension.rb b/config/initializers/ninoxe_extension.rb deleted file mode 100644 index aaeb16d76..000000000 --- a/config/initializers/ninoxe_extension.rb +++ /dev/null @@ -1,44 +0,0 @@ -# encoding: utf-8 - - -Rails.application.config.after_initialize do - - -  Chouette::TridentActiveRecord - -  class Chouette::TridentActiveRecord - -    # add referential relationship for objectid and localization functions -    def referential -      @referential ||= Referential.where(:slug => Apartment::Database.current_database).first! -    end - -    # override prefix for good prefix in objectid generation -    def prefix -      self.referential.prefix -    end - -  end - -  Chouette::StopArea - -  class Chouette::StopArea - -    include  NinoxeExtension::ProjectionFields - -    # override default_position method to add referential envelope when no stoparea is positioned -    def default_position -      # for first StopArea ... the bounds is nil , set to referential center -      Chouette::StopArea.bounds ? Chouette::StopArea.bounds.center : self.referential.envelope.center -    end - - -  end - -  Chouette::AccessPoint - -  class Chouette::AccessPoint -    include  NinoxeExtension::ProjectionFields -  end - -end
\ No newline at end of file | 
