diff options
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/engine/railties.rb | 29 |
3 files changed, 34 insertions, 5 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index cff75872b2..05cc49d40a 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -55,6 +55,7 @@ module Rails autoload :Bootstrap, 'rails/application/bootstrap' autoload :Configuration, 'rails/application/configuration' autoload :Finisher, 'rails/application/finisher' + autoload :Railties, 'rails/engine/railties' autoload :RoutesReloader, 'rails/application/routes_reloader' class << self @@ -232,11 +233,6 @@ module Rails config.helpers_paths end - def railties #:nodoc: - @railties ||= Rails::Railtie.subclasses.map(&:instance) + - Rails::Engine.subclasses.map(&:instance) - end - protected alias :build_middleware_stack :app diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 0ae2f16aba..46a6485c44 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -466,6 +466,10 @@ module Rails end end + def railties + @railties ||= self.class::Railties.new + end + # Returns a module with all the helpers defined for the engine. def helpers @helpers ||= begin diff --git a/railties/lib/rails/engine/railties.rb b/railties/lib/rails/engine/railties.rb new file mode 100644 index 0000000000..1081700cd0 --- /dev/null +++ b/railties/lib/rails/engine/railties.rb @@ -0,0 +1,29 @@ +module Rails + class Engine < Railtie + class Railties + include Enumerable + attr_reader :_all + + def initialize + @_all ||= ::Rails::Railtie.subclasses.map(&:instance) + + ::Rails::Engine.subclasses.map(&:instance) + end + + def self.engines + @engines ||= ::Rails::Engine.subclasses.map(&:instance) + end + + def each(*args, &block) + _all.each(*args, &block) + end + + def -(others) + _all - others + end + + delegate :engines, to: "self.class" + end + end +end + +ActiveSupport::Deprecation.deprecate_methods(Rails::Engine::Railties, :engines) |