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 113
113
{% endhighlight %}
114
114
115
115
When 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:
117
117
118
118
{% highlight ruby %}
119
119
attribute : name , : string , readable: : allowed ?
@@ -142,6 +142,18 @@ self.attributes_sortable_by_default = false # default true
142
142
self.attributes_schema_by_default = false # default true
143
143
{% endhighlight %}
144
144
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
+
145
157
{% include h.html tag="h4" text="2.3 Customizing Display" a="customizing-display" %}
146
158
147
159
Pass a block to ` attribute ` to customize display:
You can’t perform that action at this time.
0 commit comments