Sha256: dc968411e53da8fb4a9ba9b194b77fce5ead3320d80272671798d8481a3458a6
Contents?: true
Size: 1004 Bytes
Versions: 4
Compression:
Stored size: 1004 Bytes
Contents
# frozen_string_literal: true require_dependency 'thredded/post_view' require_dependency 'thredded/topic_view' require_dependency 'thredded/private_topic_view' module Thredded # A view model for a page of PostViews. class PostsPageView delegate :to_ary, to: :@topic_views delegate :total_pages, :current_page, :limit_value, to: :@topics_page_scope # @return [Thredded::BaseTopicView] attr_reader :topic # @param user [Thredded.user_class] the user who is viewing the posts page # @param topic [Thredded::TopicCommon] # @param posts_page_scope [ActiveRecord::Relation<Thredded::PostCommon>] def initialize(user, topic, posts_page_scope) @topics_page_scope = posts_page_scope @topic_views = posts_page_scope.map { |post| PostView.new(post, Pundit.policy!(user, post)) } @topic = "#{posts_page_scope.reflect_on_association(:postable).klass}View".constantize.from_user(topic, user) end end end
Version data entries
4 entries across 4 versions & 1 rubygems