Skip to content

Commit 2228274

Browse files
authored
Update service objects docs related to the model step (#61)
1 parent 1fdcecf commit 2228274

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/03-code-internals/19-service-objects.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ This is the generic step, you provide a name, and it will run the defined method
106106

107107
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`.
108108

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.
110110

111111
This step is also compatible with collections: if a collection is fetched but empty, the execution flow will stop.
112112

@@ -348,11 +348,11 @@ This step cannot fail.
348348

349349
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]`).
350350

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:
352352

353353
- _invalid_: will be `true` if the model has been found but is invalid.
354354
- _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.
356356

357357
### `policy(name = :default, class_name: nil)`
358358

0 commit comments

Comments
 (0)