Class: Papapi::GridRequest
- Defined in:
- lib/papapi/grid_request.rb
Constant Summary collapse
- DEFAULT_LIMIT =
30
Constants inherited from Request
Request::BODY_DATA_NAME, Request::RUN_METHOD, Request::SERVER_CLASS_NAME
Instance Attribute Summary collapse
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#sort_asc ⇒ Object
Returns the value of attribute sort_asc.
-
#sort_col ⇒ Object
Returns the value of attribute sort_col.
Attributes inherited from Request
#class_name, #method_name, #requests, #session
Instance Method Summary collapse
- #add_column(column) ⇒ Object
- #add_filter(code, op, value) ⇒ Object
- #response(http_response) ⇒ Object
- #to_data ⇒ Object
Methods inherited from Request
#add_request, #initialize, #send, #send_now, #set_param, #set_params
Constructor Details
This class inherits a constructor from Papapi::Request
Instance Attribute Details
#limit ⇒ Object
Returns the value of attribute limit.
6 7 8 |
# File 'lib/papapi/grid_request.rb', line 6 def limit @limit end |
#offset ⇒ Object
Returns the value of attribute offset.
6 7 8 |
# File 'lib/papapi/grid_request.rb', line 6 def offset @offset end |
#sort_asc ⇒ Object
Returns the value of attribute sort_asc.
6 7 8 |
# File 'lib/papapi/grid_request.rb', line 6 def sort_asc @sort_asc end |
#sort_col ⇒ Object
Returns the value of attribute sort_col.
6 7 8 |
# File 'lib/papapi/grid_request.rb', line 6 def sort_col @sort_col end |
Instance Method Details
#add_column(column) ⇒ Object
17 18 19 20 |
# File 'lib/papapi/grid_request.rb', line 17 def add_column(column) @columns = [['id']] if ! @columns @columns << [column] end |
#add_filter(code, op, value) ⇒ Object
8 9 10 11 |
# File 'lib/papapi/grid_request.rb', line 8 def add_filter(code, op, value) @filters = [] if ! @filters @filters << [code , op, value] end |
#response(http_response) ⇒ Object
13 14 15 |
# File 'lib/papapi/grid_request.rb', line 13 def response(http_response) GridResponse.new(http_response, self) end |
#to_data ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/papapi/grid_request.rb', line 22 def to_data data = super data[:filters] = @filters || [] data[:columns] = @columns || [] data[:sort_col] = sort_col || "" data[:sort_asc] = sort_asc || false data[:offset] = offset || 0 data[:limit] = limit || DEFAULT_LIMIT data end |