module Devops
  module Loader

    class << self
      def prepare_plugins
        plugins.each do |plugin|
          plugin.prepare
        end
      end

      def init_plugins
        plugins.each do |plugin|
          plugin.init
        end
      end

      def routes
        plugins.each do |plugin|
          plugin.routes
        end
      end

      def plugins &block
        return @plugins if @plugins
        if defined?(Devops::Plugin)
          @plugins = Devops::Plugin.constants.collect{|s| Devops::Plugin.const_get(s)}.select {|const| const.class == Module}
          puts @plugins.inspect
          @plugins
        end
      end

    end
  end
end
