Sha256: e0a1cdc9eed0c75aef085b139dcf0bd3402db3d6ddfd23da749b014c6c870aad

Contents?: true

Size: 807 Bytes

Versions: 20

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

module Thredded
  module UserPermissions
    module Moderate
      module IfModeratorColumnTrue
        extend ActiveSupport::Concern

        # @return [ActiveRecord::Relation<Thredded::Messageboard>] messageboards that the user can moderate
        def thredded_can_moderate_messageboards
          send(Thredded.moderator_column) ? Thredded::Messageboard.all : Thredded::Messageboard.none
        end

        # @param [Thredded::Messageboard] messageboard
        # @return [Boolean] Whether the user can moderate the given messageboard.
        def thredded_can_moderate_messageboard?(messageboard)
          scope = thredded_can_moderate_messageboards
          scope == Thredded::Messageboard.all || scope.include?(messageboard)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
thredded-1.1.0 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-1.0.1 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-1.0.0 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.16 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.15 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.14 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.13 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.12 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.11 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.10 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.9 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.8 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.7 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.6 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.5 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.4 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.3 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.1 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.16.0 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb
thredded-0.15.5 app/models/thredded/user_permissions/moderate/if_moderator_column_true.rb