Skip to content

Instantly share code, notes, and snippets.

@christopherstyles
Last active August 29, 2015 14:04
Show Gist options
  • Save christopherstyles/f83f95e17aa8806bc9db to your computer and use it in GitHub Desktop.
Save christopherstyles/f83f95e17aa8806bc9db to your computer and use it in GitHub Desktop.
Calling service objects from other services
class ArchiveInactiveUsers
def self.call(users)
users.each do |user|
UnsubscribeUserFromList.call(user)
SendGoodbyeEmail.call(user)
RemoveUserComment.call(user)
end
end
end
user = User.find(99)
ArchiveInactiveUsers.call([user])
# => "User #99 was removed from the mailing list."
# => "Sent a goodbye email to User #99."
# => "Removed comments by User #99."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment