Class: InertiaRails::ScrollMetadata::PagyAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/inertia_rails/scroll_metadata.rb

Instance Method Summary collapse

Instance Method Details

#call(metadata, **_options) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/inertia_rails/scroll_metadata.rb', line 45

def call(, **_options)
  page_name = .respond_to?(:vars) ? .vars.fetch(:page_param) : .options[:page_key]
  {
    page_name: page_name.to_s,
    previous_page: .try(:prev) || .try(:previous),
    next_page: .next,
    current_page: .page,
  }
end

#match?(metadata) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/inertia_rails/scroll_metadata.rb', line 41

def match?()
  defined?(Pagy) && .is_a?(Pagy)
end