-
-
Save sled/bb63022fac9b78ed96e5b86e667acfd7 to your computer and use it in GitHub Desktop.
This file contains 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
module MyConcept | |
class DoSomethingCommand | |
incldue Fancy::Command | |
arguments do | |
key(:user_id).required | |
key(:name).required | |
key(:email).required(format?: EMAIL_REGEX) | |
end | |
dependencies do | |
# arguments available, resolve dependencies needed to execute this action | |
# maybe even row-lock certain dependencies for the time being? | |
resolve(:user).from(Repository).by(:id => arguments[:user_id]).required | |
end | |
policy do | |
# user, dependencies, arguments available, check permissions | |
user.can_execute_xy? | |
end | |
preconditions do | |
# user, dependencies, arguments available, check whether state context is OK | |
end | |
def call | |
# the action is supposed to execute fine | |
context.success!(result) | |
context.fail!(error) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment