Module: JSONAPI::Parser::RackReqParamsParser
- Defined in:
- lib/easy/jsonapi/parser/rack_req_params_parser.rb
Overview
Used to parse the request params given from the Rack::Request object
Class Method Summary collapse
Class Method Details
.parse(rack_req_params) ⇒ JSONAPI::Request::QueryParamCollection
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/easy/jsonapi/parser/rack_req_params_parser.rb', line 29 def self.parse(rack_req_params) # rack::request.params: (string keys) # { # 'fields' => { 'articles' => 'title,body,author', 'people' => 'name' }, # 'include' => 'author,comments-likers,comments.users', # 'josh_ua' => 'demoss,simpson', # 'page' => { 'offset' => '5', 'limit' => '20' }, # 'filter' => { 'comments' => '(author/age > 21)', 'users' => '(age < 15)' }, # 'sort' => 'age,title' # } query_param_collection = JSONAPI::Request::QueryParamCollection.new rack_req_params.each do |name, value| add_the_param(name, value, query_param_collection) end query_param_collection end |