Sha256: 78cea6210dbfc2c28e2e97c6e73ee21be33d2c4f9ac09362e9d690e5b217683e
Contents?: true
Size: 1.13 KB
Versions: 19
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
19 entries across 19 versions & 1 rubygems