mirror of https://github.com/rails/rails
Merge pull request #8557 from timraymond/add_back_engines_and_deprecate
Adding Back Rails::Engine::Railties#engines Conflicts: railties/CHANGELOG.md
This commit is contained in:
commit
19bd2f2279
|
@ -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*
|
||||
|
||||
* Specify which logs to clear when using the `rake log:clear` task.
|
||||
(e.g. rake log:clear LOGS=test,staging)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 New Issue