Last active
November 28, 2016 21:56
-
-
Save apneadiving/fe64b64dfd5d72e17daa1d3477f0c3d9 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
class CreateUserFromInvitation | |
include Waterfall | |
def initialize(invitation) | |
@invitation = invitation | |
end | |
def call | |
chain { build_user } | |
when_falsy { user.save } | |
.dam { user.errors } | |
chain { UserMailer.affiliate_welcome(user).deliver_later } | |
end | |
private | |
attr_reader :user | |
def build_user | |
@user = #logic to build user goes here | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment