Sha256: 3a115d7ea88f60c6d30f9ff8d7bd08a87b1e2a97d657e1c8d3ac5ac46f5fee41

Contents?: true

Size: 737 Bytes

Versions: 2

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true
module Thredded
  # A view model for a page of PostViews.
  class PostsPageView
    delegate :to_ary,
             :present?,
             to: :@post_views
    delegate :total_pages,
             :current_page,
             :limit_value,
             to: :@paginated_scope

    # @return [Thredded::BaseTopicView]
    attr_reader :topic

    # @param user [Thredded.user_class] the user who is viewing the posts page
    # @param paginated_scope [ActiveRecord::Relation<Thredded::PostCommon>]
    def initialize(user, paginated_scope)
      @paginated_scope = paginated_scope
      @post_views      = paginated_scope.map { |post| Thredded::PostView.new(post, Pundit.policy!(user, post)) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thredded-0.9.2 app/view_models/thredded/posts_page_view.rb
thredded-0.9.1 app/view_models/thredded/posts_page_view.rb