Class: SimpleCrud::Pagination::PagyAdapter

Inherits:
Object
  • Object
show all
Includes:
Adapter
Defined in:
lib/simple_crud/pagination/pagy_adapter.rb

Overview

Assumes the controller includes Pagy::Method.

Constant Summary collapse

MAX_LIMIT_KEY =

43.5.0 renamed client_max_limit -> max_limit. Ruby < 3.3 resolves to the pre-rename 43.4.x, so pick whichever key the loaded Pagy expects.

Gem::Version.new(Pagy::VERSION) >= Gem::Version.new('43.5.0') ? :max_limit : :client_max_limit

Instance Method Summary collapse

Instance Method Details

#paginate(controller, klass, options) ⇒ Object



16
17
18
19
# File 'lib/simple_crud/pagination/pagy_adapter.rb', line 16

def paginate(controller, klass, options)
  _pagy, records = controller.send(:pagy, klass.all, MAX_LIMIT_KEY => 100)
  controller.render({ json: records }.merge(options))
end