mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
471 lines
16 KiB
HTML
471 lines
16 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>
|
|
Module: ActiveModelSerializers::Adapter::JsonApi::Error
|
|
|
|
— Documentation by YARD 0.8.7.6
|
|
|
|
</title>
|
|
|
|
<link rel="stylesheet" href="../../../css/style.css" type="text/css" charset="utf-8" />
|
|
|
|
<link rel="stylesheet" href="../../../css/common.css" type="text/css" charset="utf-8" />
|
|
|
|
<script type="text/javascript" charset="utf-8">
|
|
hasFrames = window.top.frames.main ? true : false;
|
|
relpath = '../../../';
|
|
framesUrl = "../../../frames.html#!ActiveModelSerializers/Adapter/JsonApi/Error.html";
|
|
</script>
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
<div id="header">
|
|
<div id="menu">
|
|
|
|
<a href="../../../_index.html">Index (E)</a> »
|
|
<span class='title'><span class='object_link'><a href="../../../ActiveModelSerializers.html" title="ActiveModelSerializers (module)">ActiveModelSerializers</a></span></span> » <span class='title'><span class='object_link'><a href="../../Adapter.html" title="ActiveModelSerializers::Adapter (module)">Adapter</a></span></span> » <span class='title'><span class='object_link'><a href="../JsonApi.html" title="ActiveModelSerializers::Adapter::JsonApi (class)">JsonApi</a></span></span>
|
|
»
|
|
<span class="title">Error</span>
|
|
|
|
|
|
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
|
</div>
|
|
|
|
<div id="search">
|
|
|
|
<a class="full_list_link" id="class_list_link"
|
|
href="../../../class_list.html">
|
|
Class List
|
|
</a>
|
|
|
|
<a class="full_list_link" id="method_list_link"
|
|
href="../../../method_list.html">
|
|
Method List
|
|
</a>
|
|
|
|
<a class="full_list_link" id="file_list_link"
|
|
href="../../../file_list.html">
|
|
File List
|
|
</a>
|
|
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
|
|
<iframe id="search_frame"></iframe>
|
|
|
|
<div id="content"><h1>Module: ActiveModelSerializers::Adapter::JsonApi::Error
|
|
|
|
|
|
|
|
</h1>
|
|
|
|
<dl class="box">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dt class="r1 last">Defined in:</dt>
|
|
<dd class="r1 last">lib/active_model_serializers/adapter/json_api/error.rb</dd>
|
|
|
|
</dl>
|
|
<div class="clear"></div>
|
|
|
|
|
|
<h2>Constant Summary</h2>
|
|
|
|
<dl class="constants">
|
|
|
|
<dt id="UnknownSourceTypeError-constant" class="">UnknownSourceTypeError =
|
|
<div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>rubocop:disable Style/AsciiComments</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div>
|
|
</dt>
|
|
<dd><pre class="code"><span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'>ArgumentError</span><span class='rparen'>)</span></pre></dd>
|
|
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>
|
|
Class Method Summary
|
|
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
|
</h2>
|
|
|
|
<ul class="summary">
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#attribute_error_objects-class_method" title="attribute_error_objects (class method)">+ (Object) <strong>attribute_error_objects</strong>(attribute_name, attribute_errors) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>definition: JSON Object.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#error_source-class_method" title="error_source (class method)">+ (Object) <strong>error_source</strong>(source_type, attribute_name) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>errorSource description: oneOf ☑ pointer : String ☑ parameter :
|
|
String.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#resource_errors-class_method" title="resource_errors (class method)">+ (Array<Symbol, Array<String>>) <strong>resource_errors</strong>(error_serializer, options) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Builds a JSON API Errors Object <a href="http://jsonapi.org/format/#errors" target="_parent" title="JSON API Errors">JSON API Errors</a>.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<div id="class_method_details" class="method_details_list">
|
|
<h2>Class Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="attribute_error_objects-class_method">
|
|
|
|
+ (<tt>Object</tt>) <strong>attribute_error_objects</strong>(attribute_name, attribute_errors)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>definition:</p>
|
|
|
|
<pre class="code ruby"><code class="ruby"><span class='const'>JSON</span> <span class='const'>Object</span>
|
|
</code></pre>
|
|
|
|
<p>properties:</p>
|
|
|
|
<pre class="code ruby"><code class="ruby">☐ id : String
|
|
☐ status : String
|
|
☐ code : String
|
|
☐ title : String
|
|
☑ detail : String
|
|
☐ links
|
|
☐ meta
|
|
☑ error_source</code></pre>
|
|
|
|
<p>description:</p>
|
|
|
|
<pre class="code ruby"><code class="ruby">id : A unique identifier for this particular occurrence of the problem.
|
|
status : The HTTP status code applicable to this problem, expressed as a string value
|
|
code : An application-specific error code, expressed as a string value.
|
|
title : A short, human-readable summary of the problem. It **SHOULD NOT** change from
|
|
occurrence to occurrence of the problem, except for purposes of localization.
|
|
detail : A human-readable explanation specific to this occurrence of the problem.</code></pre>
|
|
|
|
<p>structure:</p>
|
|
|
|
<pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span>
|
|
<span class='label'>title:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>SystemFailure</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
|
<span class='label'>detail:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>something went terribly wrong</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>
|
|
<span class='label'>status:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>500</span><span class='tstring_end'>'</span></span>
|
|
<span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_errorSource'>errorSource</span><span class='rparen'>)</span>
|
|
</code></pre>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
47
|
|
48
|
|
49
|
|
50
|
|
51
|
|
52
|
|
53
|
|
54</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model_serializers/adapter/json_api/error.rb', line 47</span>
|
|
|
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_attribute_error_objects'>attribute_error_objects</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_errors'>attribute_errors</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_attribute_errors'>attribute_errors</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attribute_error'>attribute_error</span><span class='op'>|</span>
|
|
<span class='lbrace'>{</span>
|
|
<span class='label'>source:</span> <span class='id identifier rubyid_error_source'>error_source</span><span class='lparen'>(</span><span class='symbol'>:pointer</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='rparen'>)</span><span class='comma'>,</span>
|
|
<span class='label'>detail:</span> <span class='id identifier rubyid_attribute_error'>attribute_error</span>
|
|
<span class='rbrace'>}</span>
|
|
<span class='kw'>end</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="error_source-class_method">
|
|
|
|
+ (<tt>Object</tt>) <strong>error_source</strong>(source_type, attribute_name)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>errorSource description:</p>
|
|
|
|
<pre class="code ruby"><code class="ruby">oneOf
|
|
☑ pointer : String
|
|
☑ parameter : String</code></pre>
|
|
|
|
<p>description:</p>
|
|
|
|
<pre class="code ruby"><code class="ruby">pointer: A JSON Pointer RFC6901 to the associated entity in the request document e.g. "/data"
|
|
for a primary data object, or "/data/attributes/title" for a specific attribute.
|
|
https://tools.ietf.org/html/rfc6901
|
|
|
|
parameter: A string indicating which query parameter caused the error</code></pre>
|
|
|
|
<p>structure:</p>
|
|
|
|
<pre class="code ruby"><code class="ruby"><span class='kw'>if</span> <span class='id identifier rubyid_is_attribute?'>is_attribute?</span>
|
|
<span class='lbrace'>{</span>
|
|
<span class='label'>pointer:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>/data/attributes/red-button</span><span class='tstring_end'>'</span></span>
|
|
<span class='rbrace'>}</span>
|
|
<span class='kw'>else</span>
|
|
<span class='lbrace'>{</span>
|
|
<span class='label'>parameter:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>pres</span><span class='tstring_end'>'</span></span>
|
|
<span class='rbrace'>}</span>
|
|
<span class='kw'>end</span>
|
|
</code></pre>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
78
|
|
79
|
|
80
|
|
81
|
|
82
|
|
83
|
|
84
|
|
85
|
|
86
|
|
87
|
|
88
|
|
89
|
|
90
|
|
91</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model_serializers/adapter/json_api/error.rb', line 78</span>
|
|
|
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_error_source'>error_source</span><span class='lparen'>(</span><span class='id identifier rubyid_source_type'>source_type</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='rparen'>)</span>
|
|
<span class='kw'>case</span> <span class='id identifier rubyid_source_type'>source_type</span>
|
|
<span class='kw'>when</span> <span class='symbol'>:pointer</span>
|
|
<span class='lbrace'>{</span>
|
|
<span class='label'>pointer:</span> <span class='const'>ActiveModelSerializers</span><span class='op'>::</span><span class='const'>JsonPointer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='symbol'>:attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='rparen'>)</span>
|
|
<span class='rbrace'>}</span>
|
|
<span class='kw'>when</span> <span class='symbol'>:parameter</span>
|
|
<span class='lbrace'>{</span>
|
|
<span class='label'>parameter:</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span>
|
|
<span class='rbrace'>}</span>
|
|
<span class='kw'>else</span>
|
|
<span class='id identifier rubyid_fail'>fail</span> <span class='const'>UnknownSourceTypeError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Unknown source type '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_source_type'>source_type</span><span class='embexpr_end'>}</span><span class='tstring_content'>' for attribute_name '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>'</span><span class='tstring_end'>"</span></span>
|
|
<span class='kw'>end</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="resource_errors-class_method">
|
|
|
|
+ (<tt>Array<Symbol, Array<String>></tt>) <strong>resource_errors</strong>(error_serializer, options)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Builds a JSON API Errors Object <a href="http://jsonapi.org/format/#errors" target="_parent" title="JSON API Errors">JSON API Errors</a></p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>error_serializer</span>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="../../../ActiveModel/Serializer/ErrorSerializer.html" title="ActiveModel::Serializer::ErrorSerializer (class)">ActiveModel::Serializer::ErrorSerializer</a></span></tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Array<Symbol, Array<String>></tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'>
|
|
<p>i.e. attribute_name, [attribute_errors]</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model_serializers/adapter/json_api/error.rb', line 13</span>
|
|
|
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_resource_errors'>resource_errors</span><span class='lparen'>(</span><span class='id identifier rubyid_error_serializer'>error_serializer</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_error_serializer'>error_serializer</span><span class='period'>.</span><span class='id identifier rubyid_as_json'>as_json</span><span class='period'>.</span><span class='id identifier rubyid_flat_map'>flat_map</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_errors'>attribute_errors</span><span class='op'>|</span>
|
|
<span class='id identifier rubyid_attribute_name'>attribute_name</span> <span class='op'>=</span> <span class='const'>JsonApi</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:transform_key_casing!</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span>
|
|
<span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_attribute_error_objects'>attribute_error_objects</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_errors'>attribute_errors</span><span class='rparen'>)</span>
|
|
<span class='kw'>end</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
Generated on Wed Jun 15 10:31:29 2016 by
|
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
0.8.7.6 (ruby-2.2.4).
|
|
</div>
|
|
|
|
</body>
|
|
</html> |