-
Notifications
You must be signed in to change notification settings - Fork 215
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
Allow organized interactors to be skipped based on :if and :unless options #128
Comments
I've been thinking about syntax details for passing options to organized interactors. Come up with several possible approaches with their advantages and downsides: Passing options hash to
|
Haha, my opinion is pretty strongly in favor of the option that didn't even make your list of favorites. 😄 I like the first option described: multiple class MyOrganizer
include Interactor::Organizer
organize do
call MyFirstInteractor, some: "options"
call MySecondInteractor, other: "options"
end
end I don't think that the DSL approach is really any different that multiple |
@hedgesky @laserlemon main missing thing in interactors - is their organization. Check out rails_workflow gem to compare how operations can be managed and organized. |
Hi @madzhuga! This conversation is specifically about building a new developer API for Interactor in which specific interactors can be skipped based on some arbitrary conditions. While |
…ganized_interactors Support conditional execution of organized interactors (Fixes collectiveidea#128)
I would like to see one of these options implemented. Let me know if I can be of help. The way I'm doing this now is with a def setup
# Skip if we don't have all the required information
if context.patient.blank?
Rails.logger.info 'CreatePatient [ SKIPPED - MISSING PATIENT INFO ]'
return false
end
...
end
def call
return if setup == false
...
end I also wouldn't mind an implementation where the context receives a It all depends on where you want to hold the logic for skipping interactors. For testing purposes, it has been nice to have the skip logic in the interactor class. But I can see it being much more concise to have the logic in the organizer. |
That's a great feature I miss here. @laserlemon How is the project maintenance going? If you say you would review I can work on a PR. |
Bump on @natebird 's suggestion ⬆️ , would be nice to have this |
I've just started doing the same as @natebird does; Skipping an interactor in the interactor itself. However this feels wrong because I'd expect the interactor to raise an error if context data is missing instead of silently returning. I'd also like to skip it in the organizer to have the logic in one place instead of scattering it in interactors and controllers calling the interactor. Is there anything I can help with to have progress here? |
No description provided.
The text was updated successfully, but these errors were encountered: