Sha256: a2869f9d2f101c7d556c53dcf35fea75f289f798df327dc1c70699370f1ad789

Contents?: true

Size: 519 Bytes

Versions: 9

Compression:

Stored size: 519 Bytes

Contents

# frozen_string_literal: true
module Thredded
  # A view model for PrivateTopic.
  class PrivateTopicView < BaseTopicView
    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

9 entries across 9 versions & 1 rubygems

Version Path
thredded-0.8.4 app/view_models/thredded/private_topic_view.rb
thredded-0.8.2 app/view_models/thredded/private_topic_view.rb
thredded-0.7.0 app/view_models/thredded/private_topic_view.rb
thredded-0.6.3 app/view_models/thredded/private_topic_view.rb
thredded-0.6.2 app/view_models/thredded/private_topic_view.rb
thredded-0.6.1 app/view_models/thredded/private_topic_view.rb
thredded-0.6.0 app/view_models/thredded/private_topic_view.rb
thredded-0.5.1 app/view_models/thredded/private_topic_view.rb
thredded-0.5.0 app/view_models/thredded/private_topic_view.rb