Sha256: 16a891df083e8c9bbd58ed13949ec7ff1d12d379e3e9739246a6fc5c2ca817ad

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require "godmin/helpers/application"
require "godmin/helpers/forms"
require "godmin/helpers/navigation"
require "godmin/helpers/translations"

module Godmin
  module ApplicationController
    extend ActiveSupport::Concern

    included do
      include Godmin::Helpers::Translations

      helper Godmin::Helpers::Application
      helper Godmin::Helpers::Forms
      helper Godmin::Helpers::Navigation
      helper Godmin::Helpers::Translations

      helper_method :authentication_enabled?
      helper_method :authorization_enabled?
      helper_method :engine_wrapper

      before_action :append_view_paths

      layout "godmin/application"
    end

    def welcome; end

    protected

    def redirect_back
      case Rails::VERSION::MAJOR
      when 4
        redirect_to :back
      when 5
        super(fallback_location: root_path)
      end
    end

    private

    def engine_wrapper
      EngineWrapper.new(self.class)
    end

    def append_view_paths
      append_view_path Godmin::Resolver.resolvers(controller_path, engine_wrapper)
    end

    def authentication_enabled?
      singleton_class.include?(Godmin::Authentication)
    end

    def authorization_enabled?
      singleton_class.include?(Godmin::Authorization)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
godmin-1.5.0 lib/godmin/application_controller.rb
godmin-1.4.0 lib/godmin/application_controller.rb
godmin-1.3.1 lib/godmin/application_controller.rb
godmin-1.3.0 lib/godmin/application_controller.rb