active_model_serializers/file.instrumentation.html
2016-06-15 10:39:35 -05:00

113 lines
5.1 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>
File: instrumentation
&mdash; 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#!file.instrumentation.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</a> &raquo;
<span class="title">File: instrumentation</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"><div id='filecontents'>
<p><a href="../README.md">Back to Guides</a></p>
<h1 id="label-Instrumentation">Instrumentation</h1>
<p>ActiveModelSerializers uses the <a
href="http://guides.rubyonrails.org/active_support_instrumentation.html#subscribing-to-an-event">ActiveSupport::Notification
API</a>, which allows for subscribing to events, such as for logging.</p>
<h2 id="label-Events">Events</h2>
<p>Name:</p>
<p><code>render.active_model_serializers</code></p>
<p>Payload (example):</p>
<pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span>
<span class='label'>serializer:</span> <span class='const'>PostSerializer</span><span class='comma'>,</span>
<span class='label'>adapter:</span> <span class='const'>ActiveModelSerializers</span><span class='op'>::</span><span class='const'>Adapter</span><span class='op'>::</span><span class='const'>Attributes</span>
<span class='rbrace'>}</span>
</code></pre>
<p>Subscribing:</p>
<pre class="code ruby"><code class="ruby"><span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>Notifications</span><span class='period'>.</span><span class='id identifier rubyid_subscribe'>subscribe</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>render.active_model_serializers</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_started'>started</span><span class='comma'>,</span> <span class='id identifier rubyid_finished'>finished</span><span class='comma'>,</span> <span class='id identifier rubyid_unique_id'>unique_id</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='op'>|</span>
<span class='comment'># whatever
</span><span class='kw'>end</span>
<span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>Notifications</span><span class='period'>.</span><span class='id identifier rubyid_subscribe'>subscribe</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>render.active_model_serializers</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span> <span class='op'>|</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='op'>|</span>
<span class='id identifier rubyid_event'>event</span> <span class='op'>=</span> <span class='const'>ActiveSupport</span><span class='op'>::</span><span class='const'>Notifications</span><span class='op'>::</span><span class='const'>Event</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
<span class='comment'># event.payload
</span> <span class='comment'># whatever
</span><span class='kw'>end</span>
</code></pre>
<h2 id="label-LogSubscriber"><a href="http://api.rubyonrails.org/classes/ActiveSupport/LogSubscriber.html">LogSubscriber</a></h2>
<p>ActiveModelSerializers includes an
<code>ActiveModelSerializers::LogSubscriber</code> that attaches to
<code>render.active_model_serializers</code>.</p>
</div></div>
<div id="footer">
Generated on Wed Jun 15 10:39:26 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>