diff options
Diffstat (limited to 'railties/lib/rails/application.rb')
-rw-r--r-- | railties/lib/rails/application.rb | 130 |
1 files changed, 63 insertions, 67 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 1a993a25cb..d5ec2cbfd9 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -79,9 +79,11 @@ module Rails @routes_reloader = nil @env_config = nil @ordered_railties = nil + @railties = nil @queue = nil end + # Returns true if the application is initialized. def initialized? @initialized end @@ -98,30 +100,6 @@ module Rails routes_reloader.reload! end - # Load the application and its railties tasks and invoke the registered hooks. - # Check <tt>Rails::Railtie.rake_tasks</tt> for more info. - def load_tasks(app=self) - initialize_tasks - super - self - end - - # Load the application console and invoke the registered hooks. - # Check <tt>Rails::Railtie.console</tt> for more info. - def load_console(app=self) - initialize_console - super - self - end - - # Load the application runner and invoke the registered hooks. - # Check <tt>Rails::Railtie.runner</tt> for more info. - def load_runner(app=self) - initialize_runner - super - self - end - # Stores some of the Rails initial environment parameters which # will be used by middlewares and engines to configure themselves. def env_config @@ -188,32 +166,9 @@ module Rails self end - # Returns the ordered railties for this application considering railties_order. - def ordered_railties #:nodoc: - @ordered_railties ||= begin - order = config.railties_order.map do |railtie| - if railtie == :main_app - self - elsif railtie.respond_to?(:instance) - railtie.instance - else - railtie - end - end - - all = (railties - order) - all.push(self) unless (all + order).include?(self) - order.push(:all) unless order.include?(:all) - - index = order.index(:all) - order[index] = all - order.reverse.flatten - end - end - def initializers #:nodoc: Bootstrap.initializers_for(self) + - super + + railties_initializers(super) + Finisher.initializers_for(self) end @@ -246,6 +201,66 @@ module Rails alias :build_middleware_stack :app + def run_tasks_blocks(app) #:nodoc: + railties.each { |r| r.run_tasks_blocks(app) } + super + require "rails/tasks" + task :environment do + $rails_rake_task = true + require_environment! + end + end + + def run_generators_blocks(app) #:nodoc: + railties.each { |r| r.run_generators_blocks(app) } + super + end + + def run_runner_blocks(app) #:nodoc: + railties.each { |r| r.run_runner_blocks(app) } + super + end + + def run_console_blocks(app) #:nodoc: + railties.each { |r| r.run_console_blocks(app) } + super + end + + # Returns the ordered railties for this application considering railties_order. + def ordered_railties #:nodoc: + @ordered_railties ||= begin + order = config.railties_order.map do |railtie| + if railtie == :main_app + self + elsif railtie.respond_to?(:instance) + railtie.instance + else + railtie + end + end + + all = (railties - order) + all.push(self) unless (all + order).include?(self) + order.push(:all) unless order.include?(:all) + + index = order.index(:all) + order[index] = all + order.reverse.flatten + end + end + + def railties_initializers(current) #:nodoc: + initializers = [] + ordered_railties.each do |r| + if r == self + initializers += current + else + initializers += r.initializers + end + end + initializers + end + def reload_dependencies? #:nodoc: config.reload_classes_only_on_change != true || reloaders.map(&:updated?).any? end @@ -305,25 +320,6 @@ module Rails end end - def initialize_tasks #:nodoc: - self.class.rake_tasks do - require "rails/tasks" - task :environment do - $rails_rake_task = true - require_environment! - end - end - end - - def initialize_console #:nodoc: - require "pp" - require "rails/console/app" - require "rails/console/helpers" - end - - def initialize_runner #:nodoc: - end - def build_original_fullpath(env) #:nodoc: path_info = env["PATH_INFO"] query_string = env["QUERY_STRING"] |