Skip to content

Commit

Permalink
reworded the doc notice about :pagy_countless_get_items returning an …
Browse files Browse the repository at this point in the history
…Array; fix typo in comment
  • Loading branch information
ddnexus committed Nov 20, 2018
1 parent 8368a99 commit fa547ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions docs/extras/countless.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ In a controller:
@pagy, @records = pagy_countless(some_scope, ...)
```

**Notice**: When using `ActiveRecord`, the `@records` is an `Array`. On the other side, the normal `Pagy` returns an `ActiveRelation`.

## Files

This extra is composed of 1 file:
Expand All @@ -47,5 +45,7 @@ This sub-method is similar to the `pagy_get_vars` sub-method, but it is called o

### pagy_countless_get_items(collection, pagy)

This sub-method is the same as the `pagy_get_items` sub-method, but it is called only by the `pagy_countless` method. (see the [pagy_get_items doc](../api/backend.md#pagy_get_itemscollection-pagy)).
This sub-method is similar to the `pagy_get_items` sub-method, but it is called only by the `pagy_countless` method. (see the [pagy_get_items doc](../api/backend.md#pagy_get_itemscollection-pagy)).

**Notice**: This method calls `to_a` on the collection in order to `pop` the eventual extra item from the result, so it returns an `Array`. That's different than the regular `pagy_get_items` method which doesn't need to call `to_a` on the collection.

2 changes: 1 addition & 1 deletion lib/pagy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.root; Pathname.new(__FILE__).dirname end

attr_reader :count, :page, :items, :vars, :pages, :last, :offset, :from, :to, :prev, :next

# Merge and validate the options, do some simple aritmetic and set the instance variables
# Merge and validate the options, do some simple arithmetic and set the instance variables
def initialize(vars)
@vars = VARS.merge(vars.delete_if{|_,v| v.nil? || v == '' }) # default vars + cleaned vars
{ count:0, items:1, outset:0, page:1 }.each do |k,min| # validate instance variables
Expand Down

0 comments on commit fa547ad

Please sign in to comment.