Module: Pagy::ElasticsearchRailsExtra::PagyAddOn
- Included in:
- Pagy
- Defined in:
- lib/pagy/extras/elasticsearch_rails.rb
Overview
Additions for the Pagy class
Instance Method Summary collapse
-
#new_from_elasticsearch_rails(response, vars = {}) ⇒ Object
Create a Pagy object from an Elasticsearch::Model::Response::Response object.
Instance Method Details
#new_from_elasticsearch_rails(response, vars = {}) ⇒ Object
Create a Pagy object from an Elasticsearch::Model::Response::Response object
38 39 40 41 42 43 |
# File 'lib/pagy/extras/elasticsearch_rails.rb', line 38 def new_from_elasticsearch_rails(response, vars = {}) vars[:items] = response.search.[:size] || 10 vars[:page] = ((response.search.[:from] || 0) / vars[:items]) + 1 vars[:count] = ElasticsearchRailsExtra.total_count(response) new(vars) end |