Sha256: 0ce8af4410cfba2f55cce021e650f027e4cbe3e25e6224b1566d58ee3f631092

Contents?: true

Size: 808 Bytes

Versions: 9

Compression:

Stored size: 808 Bytes

Contents

module Thredded
  class PrivateTopicUserPermissions
    attr_reader :private_topic, :user, :user_details, :messageboard

    def initialize(private_topic, user, user_details)
      @private_topic = private_topic
      @messageboard = private_topic.messageboard
      @user = user
      @user_details = user_details || UserDetail.new
    end

    def listable?
      if user.thredded_private_topics
        user.thredded_private_topics.for_user(user).any?
      end
    end

    def manageable?
      user_started_topic?
    end

    def readable?
      private_topic.users.include?(user)
    end

    def creatable?
      TopicUserPermissions
      .new(private_topic, user, user_details).creatable?
    end

    private

    def user_started_topic?
      user.id == private_topic.user_id
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
thredded-0.0.12 lib/thredded/private_topic_user_permissions.rb
thredded-0.0.10 lib/thredded/private_topic_user_permissions.rb
thredded-0.0.9 lib/thredded/private_topic_user_permissions.rb
thredded-0.0.8 lib/thredded/private_topic_user_permissions.rb
thredded-0.0.7 lib/thredded/private_topic_user_permissions.rb
thredded-0.0.6 lib/thredded/private_topic_user_permissions.rb
thredded-0.0.5 lib/thredded/private_topic_user_permissions.rb
thredded-0.0.4 lib/thredded/private_topic_user_permissions.rb
thredded-0.0.3 lib/thredded/private_topic_user_permissions.rb