mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
384 lines
9.6 KiB
HTML
384 lines
9.6 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>
|
|
Class: ActiveModelSerializers::FragmentCache
|
|
|
|
— 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/FragmentCache.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 (F)</a> »
|
|
<span class='title'><span class='object_link'><a href="../ActiveModelSerializers.html" title="ActiveModelSerializers (module)">ActiveModelSerializers</a></span></span>
|
|
»
|
|
<span class="title">FragmentCache</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>Class: ActiveModelSerializers::FragmentCache
|
|
|
|
|
|
|
|
</h1>
|
|
|
|
<dl class="box">
|
|
|
|
<dt class="r1">Inherits:</dt>
|
|
<dd class="r1">
|
|
<span class="inheritName">Object</span>
|
|
|
|
<ul class="fullTree">
|
|
<li>Object</li>
|
|
|
|
<li class="next">ActiveModelSerializers::FragmentCache</li>
|
|
|
|
</ul>
|
|
<a href="#" class="inheritanceTree">show all</a>
|
|
|
|
</dd>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dt class="r2 last">Defined in:</dt>
|
|
<dd class="r2 last">lib/active_model_serializers/fragment_cache.rb</dd>
|
|
|
|
</dl>
|
|
<div class="clear"></div>
|
|
|
|
|
|
|
|
|
|
|
|
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
|
<ul class="summary">
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#serializer-instance_method" title="#serializer (instance method)">- (Object) <strong>serializer</strong> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
<span class="note title readonly">readonly</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Returns the value of attribute serializer.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
<h2>
|
|
Instance Method Summary
|
|
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
|
</h2>
|
|
|
|
<ul class="summary">
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#fetch-instance_method" title="#fetch (instance method)">- (Object) <strong>fetch</strong> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>1.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#initialize-instance_method" title="#initialize (instance method)">- (FragmentCache) <strong>initialize</strong>(adapter, serializer, options) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
<span class="note title constructor">constructor</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>A new instance of FragmentCache.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
<div id="constructor_details" class="method_details_list">
|
|
<h2>Constructor Details</h2>
|
|
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="initialize-instance_method">
|
|
|
|
- (<tt><span class='object_link'><a href="" title="ActiveModelSerializers::FragmentCache (class)">FragmentCache</a></span></tt>) <strong>initialize</strong>(adapter, serializer, options)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Returns a new instance of FragmentCache</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
5
|
|
6
|
|
7
|
|
8
|
|
9</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model_serializers/fragment_cache.rb', line 5</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_adapter'>adapter</span><span class='comma'>,</span> <span class='id identifier rubyid_serializer'>serializer</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
|
<span class='ivar'>@instance_options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span>
|
|
<span class='ivar'>@adapter</span> <span class='op'>=</span> <span class='id identifier rubyid_adapter'>adapter</span>
|
|
<span class='ivar'>@serializer</span> <span class='op'>=</span> <span class='id identifier rubyid_serializer'>serializer</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="instance_attr_details" class="attr_details">
|
|
<h2>Instance Attribute Details</h2>
|
|
|
|
|
|
<span id=""></span>
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="serializer-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>serializer</strong> <span class="extras">(readonly)</span>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Returns the value of attribute serializer</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
3
|
|
4
|
|
5</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model_serializers/fragment_cache.rb', line 3</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_serializer'>serializer</span>
|
|
<span class='ivar'>@serializer</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<div id="instance_method_details" class="method_details_list">
|
|
<h2>Instance Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="fetch-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>fetch</strong>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<ol><li>
|
|
<p>Create a CachedSerializer and NonCachedSerializer from the serializer class</p>
|
|
</li><li>
|
|
<p>Serialize the above two with the given adapter</p>
|
|
</li><li>
|
|
<p>Pass their serializations to the adapter <code>::fragment_cache</code></p>
|
|
</li></ol>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model_serializers/fragment_cache.rb', line 14</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_fetch'>fetch</span>
|
|
<span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <span class='id identifier rubyid_serializer'>serializer</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span>
|
|
|
|
<span class='comment'># It will split the serializer into two, one that will be cached and one that will not
|
|
</span> <span class='id identifier rubyid_serializers'>serializers</span> <span class='op'>=</span> <span class='id identifier rubyid_fragment_serializer'>fragment_serializer</span>
|
|
|
|
<span class='comment'># Get serializable hash from both
|
|
</span> <span class='id identifier rubyid_cached_hash'>cached_hash</span> <span class='op'>=</span> <span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_serializers'>serializers</span><span class='lbracket'>[</span><span class='symbol'>:cached</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_non_cached_hash'>non_cached_hash</span> <span class='op'>=</span> <span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_serializers'>serializers</span><span class='lbracket'>[</span><span class='symbol'>:non_cached</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
|
|
|
<span class='comment'># Merge both results
|
|
</span> <span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_fragment_cache'>fragment_cache</span><span class='lparen'>(</span><span class='id identifier rubyid_cached_hash'>cached_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_non_cached_hash'>non_cached_hash</span><span class='rparen'>)</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
Generated on Tue Apr 5 11:04:39 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> |