-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add extension for ActiveRecord transactions #18
Conversation
e57dcb2
to
6392cf3
Compare
This commit introduces a new extension to Dry::Operation that allows operations to be wrapped in ActiveRecord transactions. This is useful for ensuring atomicity of operations that involve multiple steps that need to be rolled back in case of failure. The extension provides a `transaction` method that can be used to wrap steps in a transaction. The transaction will be rolled back if any of the steps return a `Dry::Monads::Result::Failure`. The extension also supports specifying a custom ActiveRecord class to initiate the transaction, which is useful when working with multiple databases.
@waiting-for-dev Hello, I'm actively implementing operations in my apps and am eager to integrate this gem. This feature would be useful for me. Can you help review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix information in doc. - Improve tests to get rid of `let!` and more reliable way to call model methods - Prevent verbose messages of AR migrations. Cleanup db after tests
This commit enhances the ActiveRecord extension of the Dry::Operation module to support additional options for the ActiveRecord transaction. These options can be set as default for all transactions or overridden at runtime. The changes include updates to the method signatures and the addition of new tests to verify the functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waiting-for-dev If you're happy with this, I'm happy with this 👍🏼 |
Just noting the build is red; we should fix that before merging :) |
The line exceeds 100 characters. Shorter param names are still good enough.
I fixed it and ran |
Hey @tiev, still read :/ |
Move the yardoc comment block to the define_method block. With the stand-alone `@!method` block, yard always generate warning of unknown parameter name.
yeah, yardoc warning concludes as failed. I've fixed it and ensured 0 exit code. |
Thanks for your brilliant work on this one, @tiev 🙌 |
Overview
The conventions of this gem have been adopted in many Rails applications using dry-monad/Do-notation. Therefore, it's useful to have an extension for ActiveRecord.
Details
This PR introduces a new extension to Dry::Operation that allows operations to be wrapped in ActiveRecord transactions. This is useful for ensuring atomicity of operations that involve multiple steps that need to be rolled back in case of failure. The extension provides a
transaction
method that can be used to wrap steps in a transaction. The transaction will be rolled back if any of the steps return aDry::Monads::Result::Failure
.The extension also supports specifying a custom ActiveRecord class to initiate the transaction, which is useful when working with multiple databases.