Sha256: 186f3360a763f1805b1622f3d3da0d0965bec984d5efd156320a0709616e34da

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module ActiveElement
  # Base controller for all ActiveElement API admin front ends, provides standard layout, menu,
  # authentication as Superuser, and standardised HTML widgets.
  class ApplicationController < ActionController::Base
    include ActionView::Helpers::TagHelper

    layout 'active_element'

    before_action -> { authenticate_user! }
    before_action -> { ActiveElement::ControllerAction.new(self).process_action }

    helper_method :active_element_component
    helper_method :render_active_element_hook

    def self.permit_user(permissions, **kwargs)
      active_element_permissions << [permissions, kwargs]

      nil
    end

    def active_element_component
      @active_element_component ||= ActiveElement::Component.new(self)
    end

    def render_active_element_hook(hook)
      render_to_string partial: "/active_element/#{hook}"
    rescue ActionView::MissingTemplate
      nil
    end

    def missing_template_store
      @missing_template_store ||= {}
    end

    def self.active_element_permissions
      @active_element_permissions ||= []
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_element-0.0.2 app/controllers/active_element/application_controller.rb