mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
387 lines
13 KiB
HTML
387 lines
13 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: ActiveModel::Serializer::IncludeTree::Parsing
|
|
|
|
— 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#!ActiveModel/Serializer/IncludeTree/Parsing.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 (P)</a> »
|
|
<span class='title'><span class='object_link'><a href="../../../ActiveModel.html" title="ActiveModel (module)">ActiveModel</a></span></span> » <span class='title'><span class='object_link'><a href="../../Serializer.html" title="ActiveModel::Serializer (class)">Serializer</a></span></span> » <span class='title'><span class='object_link'><a href="../IncludeTree.html" title="ActiveModel::Serializer::IncludeTree (class)">IncludeTree</a></span></span>
|
|
»
|
|
<span class="title">Parsing</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: ActiveModel::Serializer::IncludeTree::Parsing
|
|
|
|
|
|
|
|
</h1>
|
|
|
|
<dl class="box">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dt class="r1 last">Defined in:</dt>
|
|
<dd class="r1 last">lib/active_model/serializer/include_tree.rb</dd>
|
|
|
|
</dl>
|
|
<div class="clear"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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="#include_args_to_hash-class_method" title="include_args_to_hash (class method)">+ (Hash) <strong>include_args_to_hash</strong>(included) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Translates the arguments passed to the include option into a Hash.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#include_string_to_hash-class_method" title="include_string_to_hash (class method)">+ (Hash) <strong>include_string_to_hash</strong>(included) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Translates a comma separated list of dot separated paths (JSON API format)
|
|
into a Hash.</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="include_args_to_hash-class_method">
|
|
|
|
+ (<tt>Hash</tt>) <strong>include_args_to_hash</strong>(included)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Translates the arguments passed to the include option into a Hash. The
|
|
format can be either a String (see #include_string_to_hash), an Array of
|
|
Symbols and Hashes, or a mix of both.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<div class="examples">
|
|
<p class="tag_title">Examples:</p>
|
|
|
|
|
|
<pre class="example code"><code>`posts: [:author, comments: [:author, :upvotes]]`
|
|
|
|
would become
|
|
|
|
`{ posts: { author: {}, comments: { author: {}, upvotes: {} } } }`.</code></pre>
|
|
|
|
|
|
<pre class="example code"><code><span class='backtick'>`</span><span class='tstring_content'>[:author, :comments => [:author]]</span><span class='tstring_end'>`</span></span>
|
|
|
|
<span class='id identifier rubyid_would'>would</span> <span class='id identifier rubyid_become'>become</span>
|
|
|
|
<span class='backtick'>`</span><span class='tstring_content'>{:author => {}, :comments => { author: {} } }</span><span class='tstring_end'>`</span></span></code></pre>
|
|
|
|
</div>
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>included</span>
|
|
|
|
|
|
<span class='type'>(<tt>Symbol</tt>, <tt>Hash</tt>, <tt>Array</tt>, <tt>String</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Hash</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'>
|
|
<p>a Hash representing the same tree structure</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
46
|
|
47
|
|
48
|
|
49
|
|
50
|
|
51
|
|
52
|
|
53
|
|
54
|
|
55
|
|
56
|
|
57
|
|
58
|
|
59
|
|
60
|
|
61</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/include_tree.rb', line 46</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_include_args_to_hash'>include_args_to_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_included'>included</span><span class='rparen'>)</span>
|
|
<span class='kw'>case</span> <span class='id identifier rubyid_included'>included</span>
|
|
<span class='kw'>when</span> <span class='const'>Symbol</span>
|
|
<span class='lbrace'>{</span> <span class='id identifier rubyid_included'>included</span> <span class='op'>=></span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
|
<span class='kw'>when</span> <span class='const'>Hash</span>
|
|
<span class='id identifier rubyid_included'>included</span><span class='period'>.</span><span class='id identifier rubyid_each_with_object'>each_with_object</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_hash'>hash</span><span class='op'>|</span>
|
|
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_include_args_to_hash'>include_args_to_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
<span class='kw'>end</span>
|
|
<span class='kw'>when</span> <span class='const'>Array</span>
|
|
<span class='id identifier rubyid_included'>included</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='op'>|</span> <span class='id identifier rubyid_a'>a</span><span class='period'>.</span><span class='id identifier rubyid_deep_merge!'>deep_merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_include_args_to_hash'>include_args_to_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
|
<span class='kw'>when</span> <span class='const'>String</span>
|
|
<span class='id identifier rubyid_include_string_to_hash'>include_string_to_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_included'>included</span><span class='rparen'>)</span>
|
|
<span class='kw'>else</span>
|
|
<span class='lbrace'>{</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="include_string_to_hash-class_method">
|
|
|
|
+ (<tt>Hash</tt>) <strong>include_string_to_hash</strong>(included)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Translates a comma separated list of dot separated paths (JSON API format)
|
|
into a Hash.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<div class="examples">
|
|
<p class="tag_title">Examples:</p>
|
|
|
|
|
|
<pre class="example code"><code>`'posts.author, posts.comments.upvotes, posts.comments.author'`
|
|
|
|
would become
|
|
|
|
`{ posts: { author: {}, comments: { author: {}, upvotes: {} } } }`.</code></pre>
|
|
|
|
</div>
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>included</span>
|
|
|
|
|
|
<span class='type'>(<tt>String</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Hash</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'>
|
|
<p>a Hash representing the same tree structure</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/include_tree.rb', line 19</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_include_string_to_hash'>include_string_to_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_included'>included</span><span class='rparen'>)</span>
|
|
<span class='comment'># TODO: Needs comment walking through the process of what all this is doing.
|
|
</span> <span class='id identifier rubyid_included'>included</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'> </span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>,</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_path'>path</span><span class='op'>|</span>
|
|
<span class='id identifier rubyid_include_tree'>include_tree</span> <span class='op'>=</span> <span class='id identifier rubyid_path'>path</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>.</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_reverse_each'>reverse_each</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='op'>|</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span> <span class='op'>=></span> <span class='id identifier rubyid_a'>a</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
|
<span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_deep_merge!'>deep_merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_include_tree'>include_tree</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 Tue Apr 5 11:04:36 2016 by
|
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
0.8.7.6 (ruby-2.2.2).
|
|
</div>
|
|
|
|
</body>
|
|
</html> |