Skip to content

Commit

Permalink
Make clear that steps can be separated by regular Ruby code
Browse files Browse the repository at this point in the history
  • Loading branch information
waiting-for-dev committed Oct 31, 2024
1 parent 4a02bb3 commit dc6b6a1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docsite/source/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ end

When all steps succeed, calling this operation will return `Success(user)`, not just `user`.

It's important to notice that steps don't need to immediately follow each other. You can add your own regular Ruby code between the steps to adjust values as required. For instance, the following works just fine:

```ruby
class CreateUser < Dry::Operation
def call(input)
attrs = step validate(input)
attrs[:name] = attrs[:name].capitalize
user = step persist(attrs)
step notify(user)
user # This is automatically wrapped in Success
end

# ... other methods ...
end
```

### Handling Results

After calling an operation, you will receive either a `Success` or a `Failure`. You can pattern match on this result to handle each situation:
Expand Down

0 comments on commit dc6b6a1

Please sign in to comment.