1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Everyone receives app as argument for consistency.

This commit is contained in:
José Valim 2011-05-25 01:37:55 +02:00
parent 76cebf2e53
commit 52e01fc59d
6 changed files with 22 additions and 18 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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