Skip to content

Commit

Permalink
used ternary conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Apr 23, 2020
1 parent a9cee7d commit bba1bca
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/pagy/extras/elasticsearch_rails.rb
Expand Up @@ -13,11 +13,7 @@ class Pagy
def self.new_from_elasticsearch_rails(response, vars={})
vars[:items] = response.search.options[:size] || 10
vars[:page] = (response.search.options[:from] || 0) / vars[:items] + 1
total = if response.respond_to?(:raw_response)
response.raw_response['hits']['total']
else
response.response['hits']['total']
end
total = response.respond_to?(:raw_response) ? response.raw_response['hits']['total'] : response.response['hits']['total']
vars[:count] = total.is_a?(Hash) ? total['value'] : total
new(vars)
end
Expand Down

0 comments on commit bba1bca

Please sign in to comment.