aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application/railties.rb
blob: 14ba0afc7ce2b800cede8ae2a87f3822346c14b5 (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
30
31
module Rails
  class Application
    class Railties
      # TODO Write tests for this behavior extracted from Application
      def initialize(config)
        @config = config
      end

      def all(&block)
        @all ||= railties + engines + plugins
        @all.each(&block) if block
        @all
      end

      def railties
        @railties ||= ::Rails::Railtie.subclasses.map(&:new)
      end

      def engines
        @engines ||= ::Rails::Engine.subclasses.map(&:instance)
      end

      def plugins
        @plugins ||= begin
          plugin_names = (@config.plugins || [:all]).map { |p| p.to_sym }
          Plugin.all(plugin_names, @config.paths.vendor.plugins)
        end
      end
    end
  end
end