提交 50be56dc 编写于 作者: G Genadi Samokovarov

Refactor of ::Rails module

1. Used ActiveSupport::Autoload to dry-up the autoload definitions.
2. Used ActiveSupport's delegate to dry up the application proxied
   attributes.
3. Did a little white space change on Rails.groups.
上级 0d22947e
......@@ -3,7 +3,9 @@
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'
......@@ -20,26 +22,22 @@
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 :WelcomeController
class << self
attr_accessor :application, :cache, :logger
delegate :initialize!, :initialized?, to: :application
# The Configuration instance used to configure the Rails environment
def configuration
application.config
end
def initialize!
application.initialize!
end
def initialized?
application.initialized?
end
def backtrace_cleaner
@backtrace_cleaner ||= begin
# Relies on Active Support, so we have to lazy load to postpone definition until AS has been loaded
......@@ -76,7 +74,7 @@ def groups(*groups)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册