diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-06 18:27:16 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-08-06 18:27:16 -0700 |
commit | d25fe31c40928712b5e08fe0afb567c3bc88eddf (patch) | |
tree | 3b1134d5042c227cd1a02698f90dc96849751b69 /railties/lib | |
parent | 2090615d39c071c9eb25e715275eb79f3f9b6266 (diff) | |
download | rails-d25fe31c40928712b5e08fe0afb567c3bc88eddf.tar.gz rails-d25fe31c40928712b5e08fe0afb567c3bc88eddf.tar.bz2 rails-d25fe31c40928712b5e08fe0afb567c3bc88eddf.zip |
lazily instantiate application subclasses
this means we can meaningfully override methods in the subclass
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index ecd8c22dd8..e7172e491f 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -29,7 +29,13 @@ module Rails autoload :WelcomeController class << self - attr_accessor :application, :cache, :logger + @application = @app_class = nil + + attr_writer :application + attr_accessor :app_class, :cache, :logger + def application + @application ||= (app_class.instance if app_class) + end delegate :initialize!, :initialized?, to: :application diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index c5fd08e743..292986b475 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -87,7 +87,7 @@ module Rails class << self def inherited(base) super - base.instance + Rails.app_class = base end # Makes the +new+ method public. @@ -117,8 +117,6 @@ module Rails @railties = nil @message_verifiers = {} - Rails.application ||= self - add_lib_to_load_path! ActiveSupport.run_load_hooks(:before_configuration, self) |