Sha256: 5cecb7bcb3fcd60af67f0199e5ea1b31d85ec421445fcced7660d51690001660

Contents?: true

Size: 469 Bytes

Versions: 4

Compression:

Stored size: 469 Bytes

Contents

# frozen_string_literal: true
module Thredded
  class PrivateTopicPolicy
    # @param user [Thredded.user_class]
    # @param private_topic [Thredded::PrivateTopic]
    def initialize(user, private_topic)
      @private_topic = private_topic
      @user = user
    end

    def create?
      !@user.thredded_anonymous?
    end

    def read?
      @private_topic.users.include?(@user)
    end

    def update?
      @user.id == @private_topic.user_id
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thredded-0.4.0 app/policies/thredded/private_topic_policy.rb
thredded-0.3.2 app/policies/thredded/private_topic_policy.rb
thredded-0.3.1 app/policies/thredded/private_topic_policy.rb
thredded-0.3.0 app/policies/thredded/private_topic_policy.rb