Sha256: ebfc4541294d9c78e74e323287340dbc19ff9632df9e05f29f168771a1e627b5

Contents?: true

Size: 540 Bytes

Versions: 42

Compression:

Stored size: 540 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.thredded_anonymous? && @user.id == @private_topic.user_id
    end
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

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