Sha256: cb5a99fea7b9733c8e8c0898fd0c41d6c8be4e2fc486f482f31a2524e2a25a05
Contents?: true
Size: 1.2 KB
Versions: 61
Compression:
Stored size: 1.2 KB
Contents
# frozen_string_literal: true module Koi module Controller module HasAdminUsers extend ActiveSupport::Concern included do helper_method :admin_signed_in? helper_method :current_admin_user helper_method :current_admin end def admin_signed_in? current_admin_user.present? end def current_admin_user @current_admin_user ||= Admin::User.find(session[:admin_user_id]) if session[:admin_user_id].present? end # @deprecated Use current_admin_user instead alias_method :current_admin, :current_admin_user module Test # Include in view specs to stub out the current admin user module ViewHelper extend ActiveSupport::Concern included do before do view.singleton_class.module_eval do def admin_signed_in? current_admin_user.present? end def current_admin_user respond_to?(:admin_user) ? admin_user : nil end alias_method :current_admin, :current_admin_user end end end end end end end end
Version data entries
61 entries across 61 versions & 1 rubygems