Class: Spree::Invitations::Accept
- Defined in:
- app/workflows/spree/invitations/accept.rb
Overview
Turns an invitation into access: the invitee gains the role they were invited to, and the invitation is marked accepted.
The expiry and invitee checks were state-scoped validations on the old machine, which meant an expired invitation became a record that refused to save. As guards they refuse the acceptance itself, so the invitation is left untouched and still pending.
Instance Method Summary collapse
-
#perform(invitation:) ⇒ Spree::ServiceModule::Result
Value is the invitation.
Methods inherited from Workflow
#call, define_argument_readers, #errors, #halt!, hooks, inherited, model_name, #read_attribute_for_validation, #reject!, workflow_key
Methods included from ServiceModule::Base
Methods included from Workflow::ControlFlow
Instance Method Details
#perform(invitation:) ⇒ Spree::ServiceModule::Result
Returns value is the invitation.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/workflows/spree/invitations/accept.rb', line 15 def perform(invitation:) super step :ensure_acceptable run_hooks :validate ApplicationRecord.transaction do step :lock_invitation step :grant_role step :mark_accepted run_hooks :after_accept end invitation.publish_event('invitation.accepted') success(invitation) end |