Sha256: 7d3a8fb17aa2e961da59164526880dd2c0f25e9f0dab3419b358cd423b886f09

Contents?: true

Size: 509 Bytes

Versions: 17

Compression:

Stored size: 509 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? && !@user.thredded_user_detail.blocked?
    end

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

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
thredded-0.11.1 app/policies/thredded/private_topic_policy.rb
thredded-0.11.0 app/policies/thredded/private_topic_policy.rb
thredded-0.10.1 app/policies/thredded/private_topic_policy.rb
thredded-0.10.0 app/policies/thredded/private_topic_policy.rb
thredded-0.9.4 app/policies/thredded/private_topic_policy.rb
thredded-0.9.3 app/policies/thredded/private_topic_policy.rb
thredded-0.9.2 app/policies/thredded/private_topic_policy.rb
thredded-0.9.1 app/policies/thredded/private_topic_policy.rb
thredded-0.8.4 app/policies/thredded/private_topic_policy.rb
thredded-0.8.2 app/policies/thredded/private_topic_policy.rb
thredded-0.7.0 app/policies/thredded/private_topic_policy.rb
thredded-0.6.3 app/policies/thredded/private_topic_policy.rb
thredded-0.6.2 app/policies/thredded/private_topic_policy.rb
thredded-0.6.1 app/policies/thredded/private_topic_policy.rb
thredded-0.6.0 app/policies/thredded/private_topic_policy.rb
thredded-0.5.1 app/policies/thredded/private_topic_policy.rb
thredded-0.5.0 app/policies/thredded/private_topic_policy.rb