File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 113113{% endhighlight %}
114114
115115When guarding the ` :readable ` flag, the method can optionally accept the
116- model instance and the of the attribute being serialized as arguments:
116+ model instance and the name of the attribute being serialized as arguments:
117117
118118{% highlight ruby %}
119119attribute : name , : string , readable: : allowed ?
@@ -142,6 +142,18 @@ self.attributes_sortable_by_default = false # default true
142142self.attributes_schema_by_default = false # default true
143143{% endhighlight %}
144144
145+ As for resource defined guards, you can pass a symbol to guard the
146+ behavior globally. This can be used to globally delegate access control to a
147+ dedicated system.
148+
149+ {% highlight ruby %}
150+ self.attributes_readable_by_default = : attribute_readable ? # default true
151+
152+ def attribute_readable?(model_instance, attribute_name)
153+ PolicyChecker.new(model_instance).attribute_readable?(attribute_name)
154+ end
155+ {% endhighlight %}
156+
145157{% include h.html tag="h4" text="2.3 Customizing Display" a="customizing-display" %}
146158
147159Pass a block to ` attribute ` to customize display:
You can’t perform that action at this time.
0 commit comments