Class: WorkflowKit::DestroyAccountAndEndMembershipsIfNeededBrick
- Inherits:
-
Brick
- Object
- Brick
- WorkflowKit::DestroyAccountAndEndMembershipsIfNeededBrick
- Defined in:
- app/models/workflow_kit/destroy_account_and_end_memberships_if_needed_brick.rb
Instance Method Summary collapse
Instance Method Details
#description ⇒ Object
6 7 8 |
# File 'app/models/workflow_kit/destroy_account_and_end_memberships_if_needed_brick.rb', line 6 def description "If the user is not member of any corporation anymore: Destroy the associated UserAccount. This prevents login but keeps all user data. End all non-corporation memberships." end |
#execute(params) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/models/workflow_kit/destroy_account_and_end_memberships_if_needed_brick.rb', line 9 def execute( params ) raise 'no user_id given' unless params[ :user_id ] user = User.find( params[ :user_id ] ) if user.current_corporations.count == 0 user.account.try(:destroy) user.end_all_non_corporation_memberships end end |
#name ⇒ Object
3 4 5 |
# File 'app/models/workflow_kit/destroy_account_and_end_memberships_if_needed_brick.rb', line 3 def name "Destroy UserAccount and end all non-corporation memberships if needed." end |