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)


24
25
26
27
28
29
30
31
32
33
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 24

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_major < 43
end

.pagy_majorObject



18
19
20
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 18

def self.pagy_major
  @pagy_major ||= Pagy::VERSION.scan(/\d+/).first.to_i
end

.pagy_pre_8?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 14

def self.pagy_pre_8?
  pagy_major < 8
end

Instance Method Details

#callObject



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

def call
  render_nav.html_safe # rubocop:disable Rails/OutputSafety
end

#inspectObject



43
44
45
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 43

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

#pagy_optionsObject



39
40
41
# File 'app/components/katalyst/tables/pagy_nav_component.rb', line 39

def pagy_options
  default_pagy_options.merge(@pagy_options)
end