diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-25 01:37:55 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-25 01:37:55 +0200 |
commit | 52e01fc59dfcadaa0fd7773fb4d9a04dff297ce8 (patch) | |
tree | 1c74d37b78b4af1c5b43df667ea5176ff60256ec | |
parent | 76cebf2e5364fd929f60379be636f525c6473dcc (diff) | |
download | rails-52e01fc59dfcadaa0fd7773fb4d9a04dff297ce8.tar.gz rails-52e01fc59dfcadaa0fd7773fb4d9a04dff297ce8.tar.bz2 rails-52e01fc59dfcadaa0fd7773fb4d9a04dff297ce8.zip |
Everyone receives app as argument for consistency.
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 14 | ||||
-rw-r--r-- | railties/lib/rails/commands/console.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/railtie.rb | 10 | ||||
-rw-r--r-- | railties/test/application/console_test.rb | 7 |
6 files changed, 22 insertions, 18 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index bae2ded244..47133e77e8 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -29,8 +29,8 @@ module ActiveRecord # When loading console, force ActiveRecord::Base to be loaded # to avoid cross references when loading a constant for the # first time. Also, make it output to STDERR. - console do |sandbox| - require "active_record/railties/console_sandbox" if sandbox + console do |app| + require "active_record/railties/console_sandbox" if app.sandbox? ActiveRecord::Base.logger = Logger.new(STDERR) end diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 21e6f69b92..953233d774 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -50,7 +50,9 @@ module Rails end end - attr_accessor :assets + attr_accessor :assets, :sandbox + alias_method :sandbox?, :sandbox + delegate :default_url_options, :default_url_options=, :to => :routes # This method is called just after an application inherits from Rails::Application, @@ -96,9 +98,9 @@ module Rails self end - def load_tasks + def load_tasks(app=self) initialize_tasks - railties.all { |r| r.load_tasks } + railties.all { |r| r.load_tasks(app) } super self end @@ -111,10 +113,10 @@ module Rails self end - def load_console(sandbox=false) + def load_console(app=self) initialize_console - railties.all { |r| r.load_console(sandbox) } - super() + railties.all { |r| r.load_console(app) } + super self end diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 66dbb5d11e..32e361d421 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -23,7 +23,8 @@ module Rails opt.parse!(ARGV) end - @app.load_console(options[:sandbox]) + @app.sandbox = options[:sandbox] + @app.load_console if options[:debugger] begin diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 81a0350724..0d01a818f5 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -387,7 +387,7 @@ module Rails delegate :middleware, :root, :paths, :to => :config delegate :engine_name, :isolated?, :to => "self.class" - def load_tasks + def load_tasks(*) super paths["lib/tasks"].existent.sort.each { |ext| load(ext) } end diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 6f0ba5bce8..65c567d72f 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -173,18 +173,18 @@ module Rails def eager_load! end - def load_console(sandbox=false) - self.class.console.each { |block| block.call(sandbox) } + def load_console(app) + self.class.console.each { |block| block.call(app) } end - def load_tasks + def load_tasks(app) extend Rake::DSL if defined? Rake::DSL - self.class.rake_tasks.each(&:call) + self.class.rake_tasks.each { |block| block.call(app) } # load also tasks from all superclasses klass = self.class.superclass while klass.respond_to?(:rake_tasks) - klass.rake_tasks.each { |t| self.instance_exec(&t) } + klass.rake_tasks.each { |t| self.instance_exec(app, &t) } klass = klass.superclass end end diff --git a/railties/test/application/console_test.rb b/railties/test/application/console_test.rb index 5ae6323345..db8f1f2ac6 100644 --- a/railties/test/application/console_test.rb +++ b/railties/test/application/console_test.rb @@ -10,7 +10,8 @@ class ConsoleTest < Test::Unit::TestCase def load_environment(sandbox = false) require "#{rails_root}/config/environment" - Rails.application.load_console(sandbox) + Rails.application.sandbox = sandbox + Rails.application.load_console end def test_app_method_should_return_integration_session @@ -78,8 +79,8 @@ class ConsoleTest < Test::Unit::TestCase value = false Class.new(Rails::Railtie) do - console do |sandbox| - value = sandbox + console do |app| + value = app.sandbox? end end |