Class: WorkflowKit::AddToGroupBrick

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

Instance Method Summary collapse

Instance Method Details

#descriptionObject



7
8
9
10
# File 'app/models/workflow_kit/add_to_group_brick.rb', line 7

def description
  "Add the given user to the given group as a new member. " +
    "The new group has to be passed as a parameter to the workflow step."
end

#execute(params) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'app/models/workflow_kit/add_to_group_brick.rb', line 11

def execute( params )
  raise 'no user_id given' unless params[ :user_id ] 
  raise 'no group_id given' unless params[ :group_id ]

  user = User.find( params[ :user_id ] )  
  group = Group.find( params[ :group_id ] )

  UserGroupMembership.create( user: user, group: group )
end

#nameObject



4
5
6
# File 'app/models/workflow_kit/add_to_group_brick.rb', line 4

def name 
  "Add User to Group"
end