aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/engine/railties.rb
blob: 1081700cd05ad11b60ac245fdd9fd8e8d90f472e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)