diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/application/configurable.rb | 19 | ||||
-rw-r--r-- | railties/lib/rails/railtie.rb | 10 |
3 files changed, 21 insertions, 13 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index eba49e1520..12aa279959 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -6,6 +6,7 @@ require 'rails/engine' module Rails class Application < Engine autoload :Bootstrap, 'rails/application/bootstrap' + autoload :Configurable, 'rails/application/configurable' autoload :Configuration, 'rails/application/configuration' autoload :Finisher, 'rails/application/finisher' autoload :Railties, 'rails/application/railties' @@ -41,10 +42,6 @@ module Rails require environment if environment end - def config - @config ||= Application::Configuration.new(self.class.find_root_with_flag("config.ru", Dir.pwd)) - end - def routes ::ActionController::Routing::Routes end diff --git a/railties/lib/rails/application/configurable.rb b/railties/lib/rails/application/configurable.rb new file mode 100644 index 0000000000..f598e33965 --- /dev/null +++ b/railties/lib/rails/application/configurable.rb @@ -0,0 +1,19 @@ +module Rails + class Application + module Configurable + def self.included(base) + base.extend ClassMethods + end + + module ClassMethods + def inherited(base) + raise "You cannot inherit from a Rails::Application child" + end + end + + def config + @config ||= Application::Configuration.new(self.class.find_root_with_flag("config.ru", Dir.pwd)) + end + end + end +end
\ No newline at end of file diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 3cf358d75f..c038d0ac70 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -17,7 +17,7 @@ module Rails def inherited(base) unless abstract_railtie?(base) - base.send(:include, self::Configurable) if add_configurable?(base) + base.send(:include, self::Configurable) subclasses << base end end @@ -53,14 +53,6 @@ module Rails def abstract_railtie?(base) ABSTRACT_RAILTIES.include?(base.name) end - - # Just add configurable behavior if a Configurable module is defined - # and the class is a direct child from self. This is required to avoid - # application or plugins getting class configuration method from Railties - # and/or Engines. - def add_configurable?(base) - defined?(self::Configurable) && base.ancestors[1] == self - end end def rake_tasks |