Module: JSONAPI::Utils::Request
- 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 46 47 48 49 |
# File 'lib/jsonapi/utils/request.rb', line 40 def process_request operations = @request.operations unless JSONAPI.configuration.resource_cache.nil? operations.each {|op| op.[:cache_serializer] = resource_serializer } end results = process_operations(operations) render_results(results) rescue => e handle_exceptions(e) end |
#relationship_params ⇒ Hash
Helper to get params for relationship params.
65 66 67 |
# File 'lib/jsonapi/utils/request.rb', line 65 def relationship_params build_params_for(:relationship) end |
#resource_params ⇒ Hash
Helper to get params for the main resource.
56 57 58 |
# File 'lib/jsonapi/utils/request.rb', line 56 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 |