-
Couldn't load subscription status.
- Fork 808
Coerce pagination string params #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,10 +66,11 @@ def offset_value | |
| # Set the "limit" (`size`) value | ||
| # | ||
| def limit(value) | ||
| return self if value.to_i <= 0 | ||
| @results = nil | ||
| @records = nil | ||
| @response = nil | ||
| @per_page = value | ||
| @per_page = value.to_i | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may introduce some confusion as any value other than a string representation of a number is likely going to return 0 by calling the #to_i: This will cause the next few lines to succeed, with a size of 0 and a per_page of 0, and likely add confusion. I think it should fail loudly. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know of a way to get ruby to throw up when converting a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whatever we decide here needs to also be applied to the
|
||
|
|
||
| search.definition.update :size => @per_page | ||
| search.definition.update :from => @per_page * (@page - 1) if @page | ||
|
|
@@ -79,11 +80,12 @@ def limit(value) | |
| # Set the "offset" (`from`) value | ||
| # | ||
| def offset(value) | ||
| return self if value.to_i < 0 | ||
| @results = nil | ||
| @records = nil | ||
| @response = nil | ||
| @page = nil | ||
| search.definition.update :from => value | ||
| search.definition.update :from => value.to_i | ||
| self | ||
| end | ||
|
|
||
|
|
||