rails_cursor_pagination
rails_cursor_pagination copied to clipboard
Draft: Refactors into a Page Class
trafficstars
Again doing a few things at once that you likely would want to breakup just to spark the discussion:
Splits Paginator into two classes:
- Paginator is more of a controller class, and validates params and presents the results to the consumer
- Page is left as an internal class where the real computation happens, which exposes results like:
page(with cursor),records(just the records),page_info(metadata),total
Some other changes:
- Exposes
recordsandpage_infofrom the Page class on a public method on Paginator - addressing: https://github.com/xing/rails_cursor_pagination/issues/1 - Removes unused method
filter_valueswhich is no longer used since this PR: https://github.com/xing/rails_cursor_pagination/pull/7/files
Of course this is more a draft - no added specs etc. But I think a few benefits of this approach is to help reduce the class size; help clean up the specs (which right now are all testing the full paginator class and hence tests that should be fast - like validators, still take a lot of setup time)