Conditional except, only, include in render json for Rails
<p>Can one have conditional except, only or include options when rendering? So, like in the example below:</p>

<pre><code>render json: @post,
except: [:author]
</code></pre>

<p>Is it possible to have that except option or a similar option be conditional? </p>

<p>Ideally, something along the lines of a conditional way of doing this that allows me to deal with many different conditions and cases. </p>

<p>Like maybe something like: </p>

<pre><code>render json: @post,
except: return_excluded_keys
</code></pre>

<p><code>return_excluded_keys</code> function could return keys that need to be excluded.</p>

<p>I am using Rails 4.2.6 and Active Model Serializers 0.9.3.</p>