Class: Thredded::TopicsPageView

Inherits:
Object
  • Object
show all
Defined in:
app/view_models/thredded/topics_page_view.rb

Overview

A view model for a page of BaseTopicViews.

Instance Method Summary collapse

Constructor Details

#initialize(user, topics_page_scope, topic_view_class: TopicView) ⇒ TopicsPageView

Returns a new instance of TopicsPageView.

Parameters:

  • user (Thredded.user_class)

    the user who is viewing the topics page

  • topics_page_scope (ActiveRecord::Relation<Thredded::Topic>)

    a kaminari-decorated “.page” scope

  • topic_view_class (Class<TopicView>) (defaults to: TopicView)

    view_model for topic instances



24
25
26
27
28
29
# File 'app/view_models/thredded/topics_page_view.rb', line 24

def initialize(user, topics_page_scope, topic_view_class: TopicView)
  @topics_paginator = refine_scope(topics_page_scope)
  @topic_views = @topics_paginator.with_read_and_follow_states(user).map do |(topic, read_state, follow)|
    topic_view_class.new(topic, read_state, follow, Pundit.policy!(user, topic))
  end
end