Sha256: d5b9cf5d3f3b67b2d9b261427a194f1558cdfb09e6c9e179a3ef876169753561
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true module Thredded # A view model for a page of BaseTopicViews. class PrivateTopicsPageView delegate :each, :each_with_index, :map, :size, :to_a, :to_ary, :blank?, :empty?, to: :@topic_views delegate :total_pages, :current_page, :limit_value, to: :@topics_paginator # @param user [Thredded.user_class] the user who is viewing the private topics page # @param topics_page_scope [ActiveRecord::Relation<Thredded::PrivateTopic>] a kaminari-decorated ".page" scope def initialize(user, topics_page_scope) @topics_paginator = refine_scope(topics_page_scope) @topic_views = @topics_paginator.with_read_states(user).map do |(topic, read_state)| Thredded::PrivateTopicView.new(topic, read_state, Pundit.policy!(user, topic)) end end protected def refine_scope(topics_page_scope) topics_page_scope.includes(:user, :last_user, :users) end end end
Version data entries
3 entries across 3 versions & 1 rubygems