Sha256: 5c9378460792b1bddd85f724d2e55a598a9e62e1687cd97b1dec4a5edcc79623
Contents?: true
Size: 655 Bytes
Versions: 7
Compression:
Stored size: 655 Bytes
Contents
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/elasticsearch_rails class Pagy # Add specialized backend methods to paginate ElasticsearchRails::Results module Backend ; private # Return Pagy object and items def pagy_elasticsearch_rails(results, vars={}) pagy = Pagy.new(pagy_elasticsearch_rails_get_vars(results, vars)) return pagy, results.offset(pagy.offset).limit(pagy.items) end def pagy_elasticsearch_rails_get_vars(results, vars) # Return the merged variables to initialize the Pagy object { count: results.total, page: (params[:page] || 1)}.merge!(vars) end end end
Version data entries
7 entries across 7 versions & 1 rubygems