1
0

application_policy.rb 392 B

123456789101112131415161718192021222324
  1. # frozen_string_literal: true
  2. class ApplicationPolicy
  3. attr_reader :current_account, :record
  4. def initialize(current_account, record)
  5. @current_account = current_account
  6. @record = record
  7. end
  8. private
  9. def current_user
  10. current_account&.user
  11. end
  12. def user_signed_in?
  13. !current_user.nil?
  14. end
  15. def role
  16. current_user&.role || UserRole.nobody
  17. end
  18. end