Skip to content

Instantly share code, notes, and snippets.

@apneadiving
Last active November 28, 2016 21:56
Show Gist options
  • Save apneadiving/fe64b64dfd5d72e17daa1d3477f0c3d9 to your computer and use it in GitHub Desktop.
Save apneadiving/fe64b64dfd5d72e17daa1d3477f0c3d9 to your computer and use it in GitHub Desktop.
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