Sha256: 64f31258a82c84dd5a5bb275407de783ffa0e90456681496c41b60d3bddff197

Contents?: true

Size: 574 Bytes

Versions: 38

Compression:

Stored size: 574 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?
                     Thredded::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

38 entries across 38 versions & 2 rubygems

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