Sha256: 0e98fd34dcbeb672b50cf69cdc023ea872a82d06be653b20497f4b80e0eb02df
Contents?: true
Size: 1.13 KB
Versions: 12
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Thredded class MessageboardPolicy # The scope of readable messageboards class Scope # @param user [Thredded.user_class] # @param scope [ActiveRecord::Relation<Thredded::Messageboard>] def initialize(user, scope) @user = user @scope = scope end # @return [ActiveRecord::Relation<Thredded::Messageboards>] def resolve @scope.merge(@user.thredded_can_read_messageboards) end end # @param user [Thredded.user_class] # @param messageboard [Thredded::Messageboard] def initialize(user, messageboard) @user = user @messageboard = messageboard end def create? @user.thredded_admin? end def read? @user.thredded_admin? || @user.thredded_can_read_messageboards.include?(@messageboard) end def update? @user.thredded_admin? end def post? @user.thredded_admin? || @user.thredded_can_write_messageboards.include?(@messageboard) end def moderate? @user.thredded_admin? || @user.thredded_can_moderate_messageboards.include?(@messageboard) end end end
Version data entries
12 entries across 12 versions & 1 rubygems