Closed rafaels88 closed 5 years ago
You could do:
defmodule Pipeline do
use Opus.Pipeline
step :do_this, if: :user_allowed
step :do_another, if: &(!__MODULE__.user_allowed(&1))
end
But I can totally see unless
making the code more readable in your examples.
Proposal
Add the ability to pass a
:unless
parameter for all the stages where it is possible to pass a:if
one.The idea is that you don't need to name your functions like
not_*
in order to add a new stage to the pipeline.Context
Imagine we can perform a step only if the user is allowed.
Now, if we want to perform another step in case the user is not allowed, we would end up with something like:
Which makes us implement two different functions (
user_not_allowed
anduser_allowed
) returning the opposite of the other. This would be simplified if we could do: