Sha256: 074656ac48059a5bcad80dedc7d0f465b1e8bb92b9f651ef9bf19134f5e67ed9

Contents?: true

Size: 816 Bytes

Versions: 18

Compression:

Stored size: 816 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, topic_view: nil)
      @paginated_scope = paginated_scope
      @post_views      = paginated_scope.map do |post|
        Thredded::PostView.new(post, Pundit.policy!(user, post), topic_view: topic_view)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
threddedDANIEL-0.14.5 app/view_models/thredded/posts_page_view.rb
thredded-0.14.4 app/view_models/thredded/posts_page_view.rb
thredded-0.14.3 app/view_models/thredded/posts_page_view.rb
thredded-0.14.2 app/view_models/thredded/posts_page_view.rb
thredded-0.14.1 app/view_models/thredded/posts_page_view.rb
thredded-0.14.0 app/view_models/thredded/posts_page_view.rb
thredded-0.13.8 app/view_models/thredded/posts_page_view.rb
thredded-0.13.7 app/view_models/thredded/posts_page_view.rb
thredded-0.13.6 app/view_models/thredded/posts_page_view.rb
thredded-0.13.5 app/view_models/thredded/posts_page_view.rb
thredded-0.13.4 app/view_models/thredded/posts_page_view.rb
thredded-0.13.3 app/view_models/thredded/posts_page_view.rb
thredded-0.13.2 app/view_models/thredded/posts_page_view.rb
thredded-0.13.1 app/view_models/thredded/posts_page_view.rb
thredded-0.13.0 app/view_models/thredded/posts_page_view.rb
thredded-0.12.4 app/view_models/thredded/posts_page_view.rb
thredded-0.12.3 app/view_models/thredded/posts_page_view.rb
thredded-0.12.2 app/view_models/thredded/posts_page_view.rb