interactor
interactor copied to clipboard
Add Optional Context Contract / Verification capability
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.
I like your version because it doesn't create a dependency on ActiveModel::Validations
.
Did you consider delegating listed arguments to the context?
I was also thinking about adding a returns
method for documentation purposes. That way, we could build written documentation automatically.
thanks @smridge ! 👍
Is this gem still maintained? An approved PR has been open for a long time.