Project

seek

0.0
No commit activity in last 3 years
No release in over 3 years
A sanitizer for pagination and sorting options. It is supposed to help unify passing search options via cross-application APIs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 0.0.1
 Project Readme

Build Status

Seek

Sanitizes pagination and sorting options in a reusable and serializable way.

Installation

gem install seek

Examples

params = { page: '4', sort_direction: 'desc', per_page: '1000' }

seek = Seek.new params,
       valid_sort_bys: %w{ first_name, last_name, age },
       max_per_page: 50,
       default_per_page: 10,
       default_sort_by: :age,
       default_sort_direction: :asc

seek.page           #=> 4
seek.per_page       #=> 50
seek.sort_by        #=> 'age'
seek.sort_direction #=> 'desc
seek.order          #=> 'age desc'

seek.to_hash    #=> Returns a Hash with all the parameters listed above.