Sha256: 2f6a59f014dad7daaf6b6f08907d40e485a40b6c61f73157a25945d16caa4f8e

Contents?: true

Size: 827 Bytes

Versions: 9

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true
require_dependency 'thredded/private_topic_view'
module Thredded
  # A view model for a page of BaseTopicViews.
  class PrivateTopicsPageView
    delegate :to_ary,
             :blank?,
             :empty?,
             to: :@topic_views
    delegate :total_pages,
             :current_page,
             :limit_value,
             to: :@topics_page_scope

    # @param user [Thredded.user_class] the user who is viewing the posts page
    # @param topics_page_scope [ActiveRecord::Relation<Thredded::Topic>]
    def initialize(user, topics_page_scope)
      @topics_page_scope = topics_page_scope
      @topic_views = @topics_page_scope.with_read_states(user).map do |(topic, read_state)|
        PrivateTopicView.new(topic, read_state, Pundit.policy!(user, topic))
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

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