rails_cursor_pagination icon indicating copy to clipboard operation
rails_cursor_pagination copied to clipboard

Draft: Refactors into a Page Class

Open myxoh opened this issue 3 years ago • 0 comments
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 records and page_info from the Page class on a public method on Paginator - addressing: https://github.com/xing/rails_cursor_pagination/issues/1
  • Removes unused method filter_values which 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)

myxoh avatar Jul 08 '22 10:07 myxoh