diff options
author | Genadi Samokovarov <gsamokovarov@gmail.com> | 2013-06-11 23:37:38 +0300 |
---|---|---|
committer | Genadi Samokovarov <gsamokovarov@gmail.com> | 2013-06-12 11:42:36 +0300 |
commit | 50be56dcdeb94679106ba02168a0fc1f87265d5a (patch) | |
tree | b68f915a6fb8ba12c13dece4164fe19e378faccc /railties/lib/rails.rb | |
parent | 0d22947e00820b4e011775cfb4ede109650db070 (diff) | |
download | rails-50be56dcdeb94679106ba02168a0fc1f87265d5a.tar.gz rails-50be56dcdeb94679106ba02168a0fc1f87265d5a.tar.bz2 rails-50be56dcdeb94679106ba02168a0fc1f87265d5a.zip |
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.
Diffstat (limited to 'railties/lib/rails.rb')
-rw-r--r-- | railties/lib/rails.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index bb98bbe5bf..3a3c11d8b3 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -3,7 +3,9 @@ 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' @@ -20,26 +22,22 @@ 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 :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 @@ 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 |