Sha256: e63d47dd0e2b226e91c0e2566547b05f5a5401bff92320e482bab6e100dabd86

Contents?: true

Size: 857 Bytes

Versions: 7

Compression:

Stored size: 857 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,
             :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| PostView.new(post, Pundit.policy!(user, post)) }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thredded-0.8.4 app/view_models/thredded/posts_page_view.rb
thredded-0.8.2 app/view_models/thredded/posts_page_view.rb
thredded-0.7.0 app/view_models/thredded/posts_page_view.rb
thredded-0.6.3 app/view_models/thredded/posts_page_view.rb
thredded-0.6.2 app/view_models/thredded/posts_page_view.rb
thredded-0.6.1 app/view_models/thredded/posts_page_view.rb
thredded-0.6.0 app/view_models/thredded/posts_page_view.rb