aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails.rb')
-rw-r--r--railties/lib/rails.rb60
1 files changed, 19 insertions, 41 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb
index 2797205334..e7172e491f 100644
--- a/railties/lib/rails.rb
+++ b/railties/lib/rails.rb
@@ -3,12 +3,13 @@ require 'rails/ruby_version_check'
require 'pathname'
require 'active_support'
+require 'active_support/dependencies/autoload'
require 'active_support/core_ext/kernel/reporting'
+require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/array/extract_options'
require 'rails/application'
require 'rails/version'
-require 'rails/deprecation'
require 'active_support/railtie'
require 'action_dispatch/railtie'
@@ -20,43 +21,27 @@ silence_warnings do
end
module Rails
- autoload :Info, 'rails/info'
- autoload :InfoController, 'rails/info_controller'
- autoload :WelcomeController, 'rails/welcome_controller'
+ extend ActiveSupport::Autoload
+
+ autoload :Info
+ autoload :InfoController
+ autoload :MailersController
+ autoload :WelcomeController
class << self
- attr_accessor :application, :cache, :logger
+ @application = @app_class = nil
- # The Configuration instance used to configure the Rails environment
- def configuration
- application.config
+ attr_writer :application
+ attr_accessor :app_class, :cache, :logger
+ def application
+ @application ||= (app_class.instance if app_class)
end
- # Rails.queue is the application's queue. You can push a job onto
- # the queue by:
- #
- # Rails.queue.push job
- #
- # A job is an object that responds to +run+. Queue consumers will
- # pop jobs off of the queue and invoke the queue's +run+ method.
- #
- # Note that depending on your queue implementation, jobs may not
- # be executed in the same process as they were created in, and
- # are never executed in the same thread as they were created in.
- #
- # If necessary, a queue implementation may need to serialize your
- # job for distribution to another process. The documentation of
- # your queue will specify the requirements for that serialization.
- def queue
- application.queue
- end
+ delegate :initialize!, :initialized?, to: :application
- def initialize!
- application.initialize!
- end
-
- def initialized?
- application.initialized?
+ # The Configuration instance used to configure the Rails environment
+ def configuration
+ application.config
end
def backtrace_cleaner
@@ -72,10 +57,7 @@ module Rails
end
def env
- @_env ||= begin
- ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
- ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"])
- end
+ @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end
def env=(environment)
@@ -98,16 +80,12 @@ module Rails
env = Rails.env
groups.unshift(:default, env)
groups.concat ENV["RAILS_GROUPS"].to_s.split(",")
- groups.concat hash.map { |k,v| k if v.map(&:to_s).include?(env) }
+ groups.concat hash.map { |k, v| k if v.map(&:to_s).include?(env) }
groups.compact!
groups.uniq!
groups
end
- def version
- VERSION::STRING
- end
-
def public_path
application && Pathname.new(application.paths["public"].first)
end