Module: JSONAPI::Utils::Request
- Included in:
- JSONAPI::Utils
- Defined in:
- lib/jsonapi/utils/request.rb
Instance Method Summary collapse
-
#check_request ⇒ Object
Render an error response if the parsed request got any error.
-
#jsonapi_request_handling ⇒ Object
Setup and check request before action gets actually evaluated.
-
#process_request ⇒ String
Override the JSONAPI::ActsAsResourceController#process_request method.
-
#relationship_params ⇒ Hash
Helper to get params for relationship params.
-
#resource_params ⇒ Hash
Helper to get params for the main resource.
-
#setup_request ⇒ JSONAPI::RequestParser
Instantiate the request object.
Instance Method Details
#check_request ⇒ Object
Render an error response if the parsed request got any error.
28 29 30 |
# File 'lib/jsonapi/utils/request.rb', line 28 def check_request @request.errors.blank? || jsonapi_render_errors(json: @request) end |
#jsonapi_request_handling ⇒ Object
Setup and check request before action gets actually evaluated.
6 7 8 9 |
# File 'lib/jsonapi/utils/request.rb', line 6 def jsonapi_request_handling setup_request check_request end |
#process_request ⇒ String
Override the JSONAPI::ActsAsResourceController#process_request method.
It might be removed when the following line on JR is fixed: github.com/cerebris/jsonapi-resources/blob/release-0-8/lib/jsonapi/acts_as_resource_controller.rb#L62
40 41 42 43 44 45 |
# File 'lib/jsonapi/utils/request.rb', line 40 def process_request process_operations render_results(@operation_results) rescue => e handle_exceptions(e) end |
#relationship_params ⇒ Hash
Helper to get params for relationship params.
61 62 63 |
# File 'lib/jsonapi/utils/request.rb', line 61 def relationship_params build_params_for(:relationship) end |
#resource_params ⇒ Hash
Helper to get params for the main resource.
52 53 54 |
# File 'lib/jsonapi/utils/request.rb', line 52 def resource_params build_params_for(:resource) end |
#setup_request ⇒ JSONAPI::RequestParser
Instantiate the request object.
16 17 18 19 20 21 22 23 |
# File 'lib/jsonapi/utils/request.rb', line 16 def setup_request @request ||= JSONAPI::RequestParser.new( params, context: context, key_formatter: key_formatter, server_error_callbacks: (self.class.server_error_callbacks || []) ) end |