mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
cb2bd4aa61
commit
48d5a33269
5 changed files with 46 additions and 5 deletions
|
@ -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 @@ 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
|
||||
|
|
|
@ -468,6 +468,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
|
||||
|
|
29
railties/lib/rails/engine/railties.rb
Normal file
29
railties/lib/rails/engine/railties.rb
Normal file
|
@ -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 @@ YAML
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue