Add Optional Context Contract / Verification capability#205
Open
sufyanadam wants to merge 2 commits intocollectiveidea:masterfrom
Open
Add Optional Context Contract / Verification capability#205sufyanadam wants to merge 2 commits intocollectiveidea:masterfrom
sufyanadam wants to merge 2 commits intocollectiveidea:masterfrom
Conversation
Add a `needs_context :key1, :key2, :key3...` method to support basic context contract verification / checking. By including the `ContextValidation` module in your interactor class, you get to declare what items in the context are actually required for the interactor to work correctly. If someone tries to use an interactor without passing it any one of the required items, an error is raised.
|
We use https://gist.github.com/timlawrenz/b37f2f37cc4eaf520c979800fa9ae42a as a base class that every interactor inherits. |
sridge-ellevest
approved these changes
Nov 11, 2022
smridge
approved these changes
Nov 11, 2022
smridge
left a comment
There was a problem hiding this comment.
I definitely found this helpful in an application I worked with quite a bit 👌🏻👍🏻
Author
|
thanks @smridge ! 👍 |
|
Is this gem still maintained? An approved PR has been open for a long time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
needs_context :key1, :key2, :key3...method tosupport basic context contract verification / checking.
By including the
ContextValidationmodule in your interactorclass, you get to declare what items in the context are
actually required for the interactor to work correctly.
If someone tries to use an interactor without passing it
any one of the required items, an error is raised.