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
Copy file name to clipboardExpand all lines: docs/03-code-internals/19-service-objects.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,7 +106,7 @@ This is the generic step, you provide a name, and it will run the defined method
106
106
107
107
This specialized step helps to remove some boilerplate when dealing with models. By default, it will execute the method named `fetch_<name>`. In the above example, you can see we name our model `:user` and the corresponding method is named `fetch_user`.
108
108
109
-
Here, you can fetch (or instantiate) a model as you see fit. If the step returns a falsy value, then the execution flow will stop here. If an `ActiveRecord` model is returned, it will call `#invalid?` on it to determine whether the model is valid. If not, the execution flow will stop.
109
+
Here, you can fetch (or instantiate) a model as you see fit. If the step returns a falsy value, or an exception is raised, then the execution flow will stop here. If an `ActiveRecord` model is returned, it will call `#invalid?` on it to determine whether the model is valid. If not, the execution flow will stop.
110
110
111
111
This step is also compatible with collections: if a collection is fetched but empty, the execution flow will stop.
112
112
@@ -348,11 +348,11 @@ This step cannot fail.
348
348
349
349
This step helps to remove some boilerplate when fetching/instantiating models or a collection of models. A model can be pretty much anything (not only `ActiveRecord` models), being a single object or a collection. The result of the step will be stored in the context as `name` (so, by default, it would be `context[:model]`).
350
350
351
-
The step will fail if the model is `nil`, empty or invalid (in the case of an `ActiveRecord` object). Its result object can be inspected by accessing the `result.model.<name>` key of the main result object. The model result object exposes one or two keys:
351
+
The step will fail if the model is `nil`, empty, invalid (in the case of an `ActiveRecord` object) or if an exception is raised. Its result object can be inspected by accessing the `result.model.<name>` key of the main result object. The model result object exposes one or two keys:
352
352
353
353
-_invalid_: will be `true` if the model has been found but is invalid.
354
354
-_not_found_: will be `true` if the model was not found.
355
-
-_exception_: the exception that made the model not found.
355
+
-_exception_: the exception that caused the step to fail.
0 commit comments