Sha256: 9633dbc75d9dd108d9ad087232853c15af8a1ffdccdf8190d96a155c5cc8a04b

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require_dependency "boilerman/application_controller"

module Boilerman
  class ControllersController < ApplicationController
    def index
      @action_with_filters = [:require_admin, :require_staff]
      @action_without_filters = [:verify_authenticity_token]
      @controller_filters = ["ApplicationController"]

      @controllers = filtered_controllers
      @controllers_and_callbacks = @controllers.map do |controller|
        callbacks = controller._process_action_callbacks
        [controller, callbacks.select{|callback| callback.kind == :before}.map(&:filter)]
      end

      gon.controllers = @controllers.map{|x| x.to_s}
    end

    private

    def filtered_controllers
      # Process only controllers with callbacks and do not include
      # Boilerman's own controllers
      controllers = ActionController::Metal.descendants.reject do |controller|
        controller.parent == Boilerman || !controller.respond_to?(:_process_action_callbacks)
      end

      if params[:include_namespace]
        controllers.select!{|controller| params[:include_namespace].include?(controller.parent.to_s)}
      end

      controllers.sort_by{|c| c.to_s}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
boilerman-0.0.3 app/controllers/boilerman/controllers_controller.rb
boilerman-0.0.2 app/controllers/boilerman/controllers_controller.rb
boilerman-0.0.1 app/controllers/boilerman/controllers_controller.rb