Sha256: f38e547e5e9e26f7da19f693e10063bb5f7f8c49a3ce16309bfe8e74d0e15b3f

Contents?: true

Size: 564 Bytes

Versions: 4

Compression:

Stored size: 564 Bytes

Contents

# frozen_string_literal: true

module Thredded
  # A view model for PrivateTopic.
  class PrivateTopicView < Thredded::BaseTopicView
    delegate :users, to: :@topic

    def edit_path
      Thredded::UrlsHelper.edit_private_topic_path(@topic)
    end

    def self.from_user(topic, user)
      read_state = if user && !user.thredded_anonymous?
                     UserPrivateTopicReadState
                       .find_by(user_id: user.id, postable_id: topic.id)
                   end
      new(topic, read_state, Pundit.policy!(user, topic))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thredded-0.13.0 app/view_models/thredded/private_topic_view.rb
thredded-0.12.4 app/view_models/thredded/private_topic_view.rb
thredded-0.12.3 app/view_models/thredded/private_topic_view.rb
thredded-0.12.2 app/view_models/thredded/private_topic_view.rb