Class: Katalyst::Tables::PagyNavComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/katalyst/tables/pagy_nav_component.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection: nil, pagy: nil, **pagy_options) ⇒ PagyNavComponent

Returns a new instance of PagyNavComponent.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 16

def initialize(collection: nil, pagy: nil, **pagy_options)
  super()

  pagy ||= collection&.pagination if collection.respond_to?(:pagination)

  raise ArgumentError, "pagy is required" if pagy.blank?

  @pagy         = pagy
  @pagy_options = pagy_options
end

Class Method Details

.pagy_legacy?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 10

def self.pagy_legacy?
  Pagy::VERSION.scan(/\d+/).first.to_i <= 8
end

Instance Method Details

#callObject



27
28
29
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 27

def call
  pagy_nav(@pagy, **pagy_options).html_safe # rubocop:disable Rails/OutputSafety
end

#inspectObject



35
36
37
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 35

def inspect
  "#<#{self.class.name} pagy: #{@pagy.inspect}>"
end

#pagy_optionsObject



31
32
33
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 31

def pagy_options
  default_pagy_options.merge(@pagy_options)
end