You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use a specific `OperationsProcessor` in a `ResourceController`, override the `create_operations_processor` method:
1172
-
1173
-
```ruby
1174
-
def create_operations_processor
1175
-
CountingActiveRecordOperationsProcessor.new
1176
-
end
1177
-
```
1178
-
1179
-
The callback code will be called after each find. It will use the same options as the find operation, without the
1180
-
pagination, to collect the record count. This is stored in the `operation_meta`, which will be returned in the top level
1181
-
meta element.
1125
+
- `:find`: A `find` operation is being processed.
1126
+
- `:show`: A `show` operation is being processed.
1127
+
- `:show_relationship`: A `show_relationship` operation is being processed.
1128
+
- `:show_related_resource`: A `show_related_resource` operation is being processed.
1129
+
- `:show_related_resources`: A `show_related_resources` operation is being processed.
1130
+
- `:create_resource`: A `create_resource` operation is being processed.
1131
+
- `:remove_resource`: A `remove_resource` operation is being processed.
1132
+
- `:replace_fields`: A `replace_fields` operation is being processed.
1133
+
- `:replace_to_one_relationship`: A `replace_to_one_relationship` operation is being processed.
1134
+
- `:create_to_many_relationship`: A `create_to_many_relationship` operation is being processed.
1135
+
- `:replace_to_many_relationship`: A `replace_to_many_relationship` operation is being processed.
1136
+
- `:remove_to_many_relationship`: A `remove_to_many_relationship` operation is being processed.
1137
+
- `:remove_to_one_relationship`: A `remove_to_one_relationship` operation is being processed.
1138
+
1139
+
See [Operation Processors] (#operation-processors) for details on using OperationPprocessors
1140
+
1141
+
##### `JSONAPI::OperationsProcessor` Callbacks (a removed feature)
1142
+
1143
+
Note: The `JSONAPI::OperationsProcessor` has been removed and replaced with the `JSONAPI::OperationDispatcher`
1144
+
and `Processor` classes per resource. The callbacks have been renamed and moved to the
1145
+
`Processor`s, with the exception of the `operations` callback which is now on the controller.
1182
1146
1183
1147
### Controllers
1184
1148
@@ -1202,6 +1166,7 @@ end
1202
1166
Of course you are free to extend this as needed and override action handlers or other methods.
1203
1167
1204
1168
A jsonapi-controller generator is avaliable
1169
+
1205
1170
```
1206
1171
rails generate jsonapi:controller contact
1207
1172
```
@@ -1417,6 +1382,56 @@ class UsersController < JSONAPI::ResourceController
1417
1382
end
1418
1383
```
1419
1384
1385
+
### Operation Processors
1386
+
1387
+
OperationProcessors are called to perform the operation(s) that make up a request. The controller (through the `OperationDispatcher`), creates an `OperatorProcessor` to handle each operation. The processor is created based on the resource name, including the namespace. If a processor does not exist for a resource (namespace matters) the default operation processor is used instead. The default processor can be changed by a configuration setting.
1388
+
1389
+
Defining a custom `Processor` allows for custom callback handling of each operation type for each resource type. Forexample:
0 commit comments