Skip to content

Instantly share code, notes, and snippets.

@joegaudet
Created June 13, 2018 18:54
Show Gist options
  • Select an option

  • Save joegaudet/768c34beb8731c38b90d4ae285ad3df4 to your computer and use it in GitHub Desktop.

Select an option

Save joegaudet/768c34beb8731c38b90d4ae285ad3df4 to your computer and use it in GitHub Desktop.
module SomeDomain
class SomeProcess < Service
dependency :find_user, Users::Queries::FindByEmail
dependency :save_user, Users::Commands::Save
def call(email, some_argument)
user = find_user.(email)
if user.some_thing?(some_argument)
user.some_thing(some_argument)
end
save_user.call(user)
end
def self.call(email)
new.(email)
end
end
end
module Users
module Commands
class Save
def call(user)
user.save
end
end
end
module Queries
class FindByEmail
dependency :user_dao, User, static: true
def call(email)
user_dao.find_by(email: email)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment