Class: Dbviewer::Datatable::QueryParams
- Inherits:
-
Object
- Object
- Dbviewer::Datatable::QueryParams
- Defined in:
- lib/dbviewer/datatable/query_params.rb
Overview
QueryParams encapsulates parameters for table querying operations
Instance Attribute Summary collapse
-
#column_filters ⇒ Object
readonly
Returns the value of attribute column_filters.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#max_records ⇒ Object
readonly
Returns the value of attribute max_records.
-
#order_by ⇒ Object
readonly
Returns the value of attribute order_by.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
Instance Method Summary collapse
-
#initialize(page: 1, order_by: nil, direction: "ASC", per_page: nil, column_filters: nil, max_records: 1000) ⇒ QueryParams
constructor
Initialize query parameters with defaults.
Constructor Details
#initialize(page: 1, order_by: nil, direction: "ASC", per_page: nil, column_filters: nil, max_records: 1000) ⇒ QueryParams
Initialize query parameters with defaults
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dbviewer/datatable/query_params.rb', line 14 def initialize( page: 1, order_by: nil, direction: "ASC", per_page: nil, column_filters: nil, max_records: 1000 ) @page = [ 1, page.to_i ].max @order_by = order_by @direction = normalize_direction(direction) @per_page = normalize_per_page(per_page || 25, max_records) @column_filters = column_filters || {} @max_records = max_records end |
Instance Attribute Details
#column_filters ⇒ Object (readonly)
Returns the value of attribute column_filters.
5 6 7 |
# File 'lib/dbviewer/datatable/query_params.rb', line 5 def column_filters @column_filters end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
5 6 7 |
# File 'lib/dbviewer/datatable/query_params.rb', line 5 def direction @direction end |
#max_records ⇒ Object (readonly)
Returns the value of attribute max_records.
5 6 7 |
# File 'lib/dbviewer/datatable/query_params.rb', line 5 def max_records @max_records end |
#order_by ⇒ Object (readonly)
Returns the value of attribute order_by.
5 6 7 |
# File 'lib/dbviewer/datatable/query_params.rb', line 5 def order_by @order_by end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/dbviewer/datatable/query_params.rb', line 5 def page @page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
5 6 7 |
# File 'lib/dbviewer/datatable/query_params.rb', line 5 def per_page @per_page end |