From 38af3540ae53b9f2fbdb649a68cde3edf182fe67 Mon Sep 17 00:00:00 2001 From: kennyj Date: Tue, 29 May 2012 23:31:27 +0900 Subject: backport runner fixes to 3-2-stable Add a runner hook to Rails::Application and Rails::Engine that requires ActiveRecord::Base to avoid circular constant loading when using observers. This commit backports cc7dd66, c0ba0f0 and 8d01c61. --- railties/lib/rails/railtie.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'railties/lib/rails/railtie.rb') diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 07a122e7d0..9eb7e7c65d 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -145,6 +145,12 @@ module Rails @load_console end + def runner(&blk) + @load_runner ||= [] + @load_runner << blk if blk + @load_runner + end + def generators(&blk) @generators ||= [] @generators << blk if blk @@ -179,6 +185,10 @@ module Rails self.class.console.each { |block| block.call(app) } end + def load_runner(app=self) + self.class.runner.each { |block| block.call(app) } + end + def load_tasks(app=self) extend Rake::DSL if defined? Rake::DSL self.class.rake_tasks.each { |block| self.instance_exec(app, &block) } -- cgit v1.2.3