Sha256: ca5c4dc7c81ec890be456f4077e9558c0b7ebb389d0292a694897c6ecf9725ae

Contents?: true

Size: 683 Bytes

Versions: 5

Compression:

Stored size: 683 Bytes

Contents

# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/searchkick

class Pagy
  # Add specialized backend methods to paginate Searchkick::Results
  module Backend ; private
    # Return Pagy object and items
    def pagy_searchkick(results, vars={})
      pagy = Pagy.new(pagy_searchkick_get_vars(results, vars))
      return pagy, results
    end

    # Sub-method called only by #pagy_searchkick: here for easy customization of variables by overriding
    def pagy_searchkick_get_vars(results, vars)
      vars[:count] ||= results.total_count
      vars[:page]  ||= results.options[:page]
      vars[:items] ||= results.options[:per_page]
      vars
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pagy-1.3.3 lib/pagy/extras/searchkick.rb
pagy-1.3.2 lib/pagy/extras/searchkick.rb
pagy-1.3.1 lib/pagy/extras/searchkick.rb
pagy-1.3 lib/pagy/extras/searchkick.rb
pagy-1.2.1 lib/pagy/extras/searchkick.rb