Class: Railsboot::PaginationComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/pagination_component.rb

Overview

ViewComponent: renders the pagination block.

Instance Method Summary collapse

Constructor Details

#initialize(pagy:) ⇒ PaginationComponent

Returns a new instance of PaginationComponent.

Parameters:

  • pagy (Pagy)

    the pagy pagination object to render



5
6
7
# File 'app/components/railsboot/pagination_component.rb', line 5

def initialize(pagy:)
  @pagy = pagy
end

Instance Method Details

#render?Boolean

Whether the component should render at all, only when there is more
than one page of results.

Returns:

  • (Boolean)

    true when +pagy+ is present and has more than one page



12
13
14
# File 'app/components/railsboot/pagination_component.rb', line 12

def render?
  @pagy.present? && @pagy.last.to_i > 1
end