Permalink
Browse files

Adding Back Rails::Engine::Railties#engines

Removing it breaks functionality with gems such as Thinking Sphinx.
This restores it with a deprecation warning. Closes #8551
  • Loading branch information...
1 parent cb2bd4a commit 48d5a33269eac16e7927c8811bfdc6010a965959 @timraymond timraymond committed Dec 19, 2012
View
@@ -1,5 +1,11 @@
## Rails 4.0.0 (unreleased) ##
+* Restore Rails::Engine::Railties#engines with deprecation to ensure
+ compatibility with gems such as Thinking Sphinx
+ Fix #8551
+
+ *Tim Raymond*
+
* Add `-B` alias for `--skip-bundle` option in the rails new generators.
*Jiri Pospisil*
@@ -55,6 +55,7 @@ class Application < Engine
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 @@ def helpers_paths #:nodoc:
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
@@ -468,6 +468,10 @@ def eager_load!
end
end
+ def railties
+ @railties ||= self.class::Railties.new
@pixeltrix

pixeltrix Feb 26, 2013

Owner

I'm guessing that @timraymond did it this way because that's how it is in 3-2-stable:
https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/engine.rb#L445

It used to be like your gist until @drogus changed it in 32a5b49.

+ end
+
# Returns a module with all the helpers defined for the engine.
def helpers
@helpers ||= begin
@@ -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)
@@ -1241,6 +1241,12 @@ def index
assert_equal '/foo/bukkits/bukkit', last_response.body
end
+ test "engines method is properly deprecated" do
+ boot_rails
+
+ assert_deprecated { app.railties.engines }
+ end
+
private
def app
Rails.application

0 comments on commit 48d5a33

Please sign in to comment.