Sha256: 677eabf7d326f48748f10dc23de2e6a9240309b375495461af2002b375534dd5
Contents?: true
Size: 1.51 KB
Versions: 4
Compression:
Stored size: 1.51 KB
Contents
module Para module Admin class BaseController < Para::ApplicationController include Para::Admin::BaseHelper if Para.config.authenticate_admin_method before_action Para.config.authenticate_admin_method end before_action :authorize_admin_access before_action :load_component_sections layout 'para/admin' helper_method :current_admin def current_admin @current_admin ||= if Para.config.current_admin_method send(Para.config.current_admin_method) end end def current_ability @current_ability ||= if (class_name = Para::Config.ability_class_name) class_name.constantize.new(current_admin) end end private def authorize_admin_access authorize! :access, :admin end def load_component_sections @component_sections = Para::ComponentSection.ordered.includes(:components) end def self.load_and_authorize_component(options = {}) before_action do load_and_authorize_component(options) end end def load_and_authorize_component(options = {}) options.reverse_merge!(class: 'Para::Component::Base', find_by: :slug) loader = self.class.cancan_resource_class.new(self, :component, options) loader.load_and_authorize_resource ActiveDecorator::Decorator.instance.decorate(@component) if @component add_breadcrumb(@component.name, @component.path) if @component end end end end
Version data entries
4 entries across 4 versions & 1 rubygems