Class: WorkflowKit::DestroyAccountAndEndMembershipsIfNeededBrick

Inherits:
Brick
  • Object
show all
Defined in:
app/models/workflow_kit/destroy_account_and_end_memberships_if_needed_brick.rb

Instance Method Summary collapse

Instance Method Details

#descriptionObject



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..try(:destroy)
    user.end_all_non_corporation_memberships
  end
end

#nameObject



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