about summary refs log tree commit diff
path: root/app/policies/application_policy.rb
blob: fd45f2b34432c7ef4f290b6273618775100d038e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

class ApplicationPolicy
  attr_reader :current_account, :record

  def initialize(current_account, record)
    @current_account = current_account
    @record          = record
  end

  delegate :admin?, :moderator?, :halfmod?, :staff?, :can_moderate?, :defanged?, :has_more_authority_than?, to: :current_user, allow_nil: true

  private

  def current_user
    current_account&.user
  end

  def user_signed_in?
    !current_user.nil?
  end
end