mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
923 lines
27 KiB
HTML
923 lines
27 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::Caching::ClassMethods
|
|
|
|
— 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/Caching/ClassMethods.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 (C)</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="../Caching.html" title="ActiveModel::Serializer::Caching (module)">Caching</a></span></span>
|
|
»
|
|
<span class="title">ClassMethods</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::Caching::ClassMethods
|
|
|
|
|
|
|
|
</h1>
|
|
|
|
<dl class="box">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dt class="r1 last">Defined in:</dt>
|
|
<dd class="r1 last">lib/active_model/serializer/caching.rb</dd>
|
|
|
|
</dl>
|
|
<div class="clear"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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="#_skip_digest%3F-instance_method" title="#_skip_digest? (instance method)">- (Boolean) <strong>_skip_digest?</strong> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#cache-instance_method" title="#cache (instance method)">- (Object) <strong>cache</strong>(options = {}) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Enables a serializer to be automatically cached.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#cache_enabled%3F-instance_method" title="#cache_enabled? (instance method)">- (Boolean) <strong>cache_enabled?</strong> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#cache_store-instance_method" title="#cache_store (instance method)">- (nil, ...) <strong>cache_store</strong> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>The canonical method for getting the cache store for the serializer.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#digest_caller_file-instance_method" title="#digest_caller_file (instance method)">- (Object) <strong>digest_caller_file</strong>(caller_line) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Hashes contents of file for <code>_cache_digest</code>.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#fragment_cache_enabled%3F-instance_method" title="#fragment_cache_enabled? (instance method)">- (Boolean) <strong>fragment_cache_enabled?</strong> </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#fragmented-instance_method" title="#fragmented (instance method)">- (Object) <strong>fragmented</strong>(serializer) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="private note title">private</span>
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Used by FragmentCache on the CachedSerializer to call attribute methods on
|
|
the fragmented cached serializer.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#inherited-instance_method" title="#inherited (instance method)">- (Object) <strong>inherited</strong>(base) </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#perform_caching-instance_method" title="#perform_caching (instance method)">- (true, false) <strong>perform_caching</strong> </a>
|
|
|
|
|
|
|
|
(also: #perform_caching?)
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'>
|
|
<p>Value is from ActiveModelSerializers.config.perform_caching.</p>
|
|
</div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<div id="instance_method_details" class="method_details_list">
|
|
<h2>Instance Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="_skip_digest?-instance_method">
|
|
|
|
- (<tt>Boolean</tt>) <strong>_skip_digest?</strong>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Boolean</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
61
|
|
62
|
|
63</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 61</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid__skip_digest?'>_skip_digest?</span>
|
|
<span class='id identifier rubyid__cache_options'>_cache_options</span> <span class='op'>&&</span> <span class='id identifier rubyid__cache_options'>_cache_options</span><span class='lbracket'>[</span><span class='symbol'>:skip_digest</span><span class='rbracket'>]</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="cache-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>cache</strong>(options = {})
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<div class="note todo">
|
|
<strong>TODO:</strong>
|
|
<div class='inline'>
|
|
<p>require less code comments. See</p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<p>Enables a serializer to be automatically cached</p>
|
|
|
|
<p>Sets <code>::_cache</code> object to
|
|
<code>ActionController::Base.cache_store</code></p>
|
|
|
|
<pre class="code ruby"><code class="ruby">when Rails.configuration.action_controller.perform_caching</code></pre>
|
|
|
|
<p><a
|
|
href="https://github.com/rails-api/active_model_serializers/pull/1249#issuecomment-146567837">github.com/rails-api/active_model_serializers/pull/1249#issuecomment-146567837</a></p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<div class="examples">
|
|
<p class="tag_title">Examples:</p>
|
|
|
|
|
|
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>PostSerializer</span> <span class='op'><</span> <span class='const'>ActiveModel</span><span class='op'>::</span><span class='const'>Serializer</span>
|
|
<span class='id identifier rubyid_cache'>cache</span> <span class='label'>key:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>post</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>expires_in:</span> <span class='int'>3</span><span class='period'>.</span><span class='id identifier rubyid_hours'>hours</span>
|
|
<span class='id identifier rubyid_attributes'>attributes</span> <span class='symbol'>:title</span><span class='comma'>,</span> <span class='symbol'>:body</span>
|
|
|
|
<span class='id identifier rubyid_has_many'>has_many</span> <span class='symbol'>:comments</span>
|
|
<span class='kw'>end</span></code></pre>
|
|
|
|
</div>
|
|
<p class="tag_title">Parameters:</p>
|
|
<ul class="param">
|
|
|
|
<li>
|
|
|
|
<span class='name'>options</span>
|
|
|
|
|
|
<span class='type'>(<tt>Hash</tt>)</span>
|
|
|
|
|
|
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
|
|
|
|
—
|
|
<div class='inline'>
|
|
<p>with valid keys: cache_store : @see ::_cache key : @see
|
|
::_cache_key only : @see ::_cache_only except : @see
|
|
::_cache_except skip_digest : does not include digest in cache_key all
|
|
else : @see ::_cache_options</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
95
|
|
96
|
|
97
|
|
98
|
|
99
|
|
100
|
|
101
|
|
102
|
|
103
|
|
104</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 95</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_cache'>cache</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__cache'>_cache</span> <span class='op'>=</span>
|
|
<span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:cache_store</span><span class='rparen'>)</span> <span class='op'>||</span>
|
|
<span class='const'>ActiveModelSerializers</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_cache_store'>cache_store</span> <span class='op'>||</span>
|
|
<span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>Cache</span><span class='period'>.</span><span class='id identifier rubyid_lookup_store'>lookup_store</span><span class='lparen'>(</span><span class='symbol'>:null_store</span><span class='rparen'>)</span>
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__cache_key'>_cache_key</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:key</span><span class='rparen'>)</span>
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__cache_only'>_cache_only</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:only</span><span class='rparen'>)</span>
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__cache_except'>_cache_except</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:except</span><span class='rparen'>)</span>
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__cache_options'>_cache_options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span> <span class='op'>?</span> <span class='kw'>nil</span> <span class='op'>:</span> <span class='id identifier rubyid_options'>options</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="cache_enabled?-instance_method">
|
|
|
|
- (<tt>Boolean</tt>) <strong>cache_enabled?</strong>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Boolean</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
140
|
|
141
|
|
142</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 140</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_cache_enabled?'>cache_enabled?</span>
|
|
<span class='id identifier rubyid_perform_caching?'>perform_caching?</span> <span class='op'>&&</span> <span class='id identifier rubyid_cache_store'>cache_store</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid__cache_only'>_cache_only</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid__cache_except'>_cache_except</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="cache_store-instance_method">
|
|
|
|
- (<tt>nil</tt>, ...) <strong>cache_store</strong>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>The canonical method for getting the cache store for the serializer.</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>nil</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'>
|
|
<p>when _cache is not set (i.e. when `cache` has not been called)</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>._cache</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'>
|
|
<p>when _cache is not the NullStore</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt><span class='object_link'><a href="../../../ActiveModelSerializers.html" title="ActiveModelSerializers (module)">ActiveModelSerializers</a></span>.config.cache_store</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'>
|
|
<p>when _cache is the NullStore. This is so we can use `cache` being called to
|
|
mean the serializer should be cached even if
|
|
ActiveModelSerializers.config.cache_store has not yet been set. That means
|
|
that when _cache is the NullStore and
|
|
ActiveModelSerializers.config.cache_store is configured, `cache_store`
|
|
becomes `ActiveModelSerializers.config.cache_store`.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>nil</tt>)</span>
|
|
|
|
|
|
|
|
—
|
|
<div class='inline'>
|
|
<p>when _cache is the NullStore and ActiveModelSerializers.config.cache_store
|
|
is nil.</p>
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
130
|
|
131
|
|
132
|
|
133
|
|
134
|
|
135
|
|
136
|
|
137
|
|
138</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 130</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_cache_store'>cache_store</span>
|
|
<span class='kw'>return</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid__cache'>_cache</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
|
<span class='kw'>return</span> <span class='id identifier rubyid__cache'>_cache</span> <span class='kw'>if</span> <span class='id identifier rubyid__cache'>_cache</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span> <span class='op'>!=</span> <span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>Cache</span><span class='op'>::</span><span class='const'>NullStore</span>
|
|
<span class='kw'>if</span> <span class='const'>ActiveModelSerializers</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_cache_store'>cache_store</span>
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__cache'>_cache</span> <span class='op'>=</span> <span class='const'>ActiveModelSerializers</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_cache_store'>cache_store</span>
|
|
<span class='kw'>else</span>
|
|
<span class='kw'>nil</span>
|
|
<span class='kw'>end</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="digest_caller_file-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>digest_caller_file</strong>(caller_line)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Hashes contents of file for <code>_cache_digest</code></p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
48
|
|
49
|
|
50
|
|
51
|
|
52
|
|
53
|
|
54
|
|
55
|
|
56
|
|
57
|
|
58
|
|
59</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 48</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_digest_caller_file'>digest_caller_file</span><span class='lparen'>(</span><span class='id identifier rubyid_caller_line'>caller_line</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_serializer_file_path'>serializer_file_path</span> <span class='op'>=</span> <span class='id identifier rubyid_caller_line'>caller_line</span><span class='lbracket'>[</span><span class='const'>CALLER_FILE</span><span class='rbracket'>]</span>
|
|
<span class='id identifier rubyid_serializer_file_contents'>serializer_file_contents</span> <span class='op'>=</span> <span class='const'>IO</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='id identifier rubyid_serializer_file_path'>serializer_file_path</span><span class='rparen'>)</span>
|
|
<span class='const'>Digest</span><span class='op'>::</span><span class='const'>MD5</span><span class='period'>.</span><span class='id identifier rubyid_hexdigest'>hexdigest</span><span class='lparen'>(</span><span class='id identifier rubyid_serializer_file_contents'>serializer_file_contents</span><span class='rparen'>)</span>
|
|
<span class='kw'>rescue</span> <span class='const'>TypeError</span><span class='comma'>,</span> <span class='const'>Errno</span><span class='op'>::</span><span class='const'>ENOENT</span>
|
|
<span class='id identifier rubyid_warn'>warn</span> <span class='heredoc_beg'><<-EOF</span><span class='period'>.</span><span class='id identifier rubyid_strip_heredoc'>strip_heredoc</span>
|
|
<span class='tstring_content'> Cannot digest non-existent file: '</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_caller_line'>caller_line</span><span class='embexpr_end'>}</span><span class='tstring_content'>'.
|
|
Please set `::_cache_digest` of the serializer
|
|
if you'd like to cache it.
|
|
</span><span class='heredoc_end'> EOF
|
|
</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="fragment_cache_enabled?-instance_method">
|
|
|
|
- (<tt>Boolean</tt>) <strong>fragment_cache_enabled?</strong>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>Boolean</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
144
|
|
145
|
|
146
|
|
147</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 144</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_fragment_cache_enabled?'>fragment_cache_enabled?</span>
|
|
<span class='id identifier rubyid_perform_caching?'>perform_caching?</span> <span class='op'>&&</span> <span class='id identifier rubyid_cache_store'>cache_store</span> <span class='op'>&&</span>
|
|
<span class='lparen'>(</span><span class='id identifier rubyid__cache_only'>_cache_only</span> <span class='op'>&&</span> <span class='op'>!</span><span class='id identifier rubyid__cache_except'>_cache_except</span> <span class='op'>||</span> <span class='op'>!</span><span class='id identifier rubyid__cache_only'>_cache_only</span> <span class='op'>&&</span> <span class='id identifier rubyid__cache_except'>_cache_except</span><span class='rparen'>)</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="fragmented-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>fragmented</strong>(serializer)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
<p class="note private">
|
|
<strong>This method is part of a private API.</strong>
|
|
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
</p>
|
|
|
|
<p>Used by FragmentCache on the CachedSerializer</p>
|
|
|
|
<pre class="code ruby"><code class="ruby">to call attribute methods on the fragmented cached serializer.</code></pre>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
68
|
|
69
|
|
70</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 68</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_fragmented'>fragmented</span><span class='lparen'>(</span><span class='id identifier rubyid_serializer'>serializer</span><span class='rparen'>)</span>
|
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__fragmented'>_fragmented</span> <span class='op'>=</span> <span class='id identifier rubyid_serializer'>serializer</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="inherited-instance_method">
|
|
|
|
- (<tt>Object</tt>) <strong>inherited</strong>(base)
|
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
41
|
|
42
|
|
43
|
|
44
|
|
45</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 41</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_inherited'>inherited</span><span class='lparen'>(</span><span class='id identifier rubyid_base'>base</span><span class='rparen'>)</span>
|
|
<span class='kw'>super</span>
|
|
<span class='id identifier rubyid_caller_line'>caller_line</span> <span class='op'>=</span> <span class='id identifier rubyid_caller'>caller</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
|
<span class='id identifier rubyid_base'>base</span><span class='period'>.</span><span class='id identifier rubyid__cache_digest'>_cache_digest</span> <span class='op'>=</span> <span class='id identifier rubyid_digest_caller_file'>digest_caller_file</span><span class='lparen'>(</span><span class='id identifier rubyid_caller_line'>caller_line</span><span class='rparen'>)</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="method_details ">
|
|
<h3 class="signature " id="perform_caching-instance_method">
|
|
|
|
- (<tt>true</tt>, <tt>false</tt>) <strong>perform_caching</strong>
|
|
|
|
|
|
|
|
<span class="aliases">Also known as:
|
|
<span class="names"><span id='perform_caching?-instance_method'>perform_caching?</span></span>
|
|
</span>
|
|
|
|
|
|
|
|
</h3><div class="docstring">
|
|
<div class="discussion">
|
|
|
|
<p>Value is from ActiveModelSerializers.config.perform_caching. Is used to
|
|
globally enable or disable all serializer caching, just like
|
|
Rails.configuration.action_controller.perform_caching, which is its default
|
|
value in a Rails application. Memoizes value of config first time it is
|
|
called with a non-nil value. rubocop:disable Style/ClassVars</p>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<div class="tags">
|
|
|
|
<p class="tag_title">Returns:</p>
|
|
<ul class="return">
|
|
|
|
<li>
|
|
|
|
|
|
<span class='type'>(<tt>true</tt>, <tt>false</tt>)</span>
|
|
|
|
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
113
|
|
114
|
|
115
|
|
116</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/active_model/serializer/caching.rb', line 113</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_perform_caching'>perform_caching</span>
|
|
<span class='kw'>return</span> <span class='cvar'>@@perform_caching</span> <span class='kw'>if</span> <span class='kw'>defined?</span><span class='lparen'>(</span><span class='cvar'>@@perform_caching</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='op'>!</span><span class='cvar'>@@perform_caching</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
|
<span class='cvar'>@@perform_caching</span> <span class='op'>=</span> <span class='const'>ActiveModelSerializers</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_perform_caching'>perform_caching</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> |