mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
110 lines
3.2 KiB
HTML
110 lines
3.2 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: key_transforms
|
|
|
|
— 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.key_transforms.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> »
|
|
<span class="title">File: key_transforms</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-Key+Transforms">Key Transforms</h1>
|
|
|
|
<p>Key Transforms modify the casing of keys and keys referenced in values in
|
|
serialized responses.</p>
|
|
|
|
<p>Provided key transforms:</p>
|
|
|
|
<p>| Option | Result | |—-|—-| | <code>:camel</code> | ExampleKey | |
|
|
<code>:camel_lower</code> | exampleKey | | <code>:dash</code> | example-key
|
|
| | <code>:unaltered</code> | the original, unaltered key | |
|
|
<code>:underscore</code> | example_key | | <code>nil</code> | use the
|
|
adapter default |</p>
|
|
|
|
<p>Key translation precedence is as follows:</p>
|
|
|
|
<h5 id="label-Adapter+option">Adapter option</h5>
|
|
|
|
<p><code>key_transform</code> is provided as an option via render.</p>
|
|
|
|
<pre class="code ruby"><code class="ruby">json: posts, each_serializer: PostSerializer, key_transform: :camel_lower</code></pre>
|
|
|
|
<h5 id="label-Configuration+option">Configuration option</h5>
|
|
|
|
<p><code>key_transform</code> is set in
|
|
<code>ActiveModelSerializers.config.key_transform</code>.</p>
|
|
|
|
<pre class="code ruby"><code class="ruby">= :camel_lower</code></pre>
|
|
|
|
<h5 id="label-Adapter+default">Adapter default</h5>
|
|
|
|
<p>Each adapter has a default transform configured:</p>
|
|
|
|
<p>| Adapter | Default Key Transform | |—-|—-| | <code>Json</code> |
|
|
<code>:unaltered</code> | | <code>JsonApi</code> | <code>:dash</code> |</p>
|
|
</div></div>
|
|
|
|
<div id="footer">
|
|
Generated on Thu Jun 16 09:05:04 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> |