Sha256: b4a50908257d7975229a1edd4831b255ba9504938114073832602128771fbc47

Contents?: true

Size: 757 Bytes

Versions: 3

Compression:

Stored size: 757 Bytes

Contents

# frozen_string_literal: true
module Thredded
  # A view model for a page of PostViews.
  class PostsPageView
    delegate :to_a,
             :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

3 entries across 3 versions & 1 rubygems

Version Path
thredded-0.10.0 app/view_models/thredded/posts_page_view.rb
thredded-0.9.4 app/view_models/thredded/posts_page_view.rb
thredded-0.9.3 app/view_models/thredded/posts_page_view.rb