Class: Decidim::RejectGroupInvitation

Inherits:
Rectify::Command
  • Object
show all
Defined in:
decidim-core/app/commands/decidim/reject_group_invitation.rb

Overview

A command with all the business logic to reject an invitation to belong to a group.

Instance Method Summary collapse

Constructor Details

#initialize(user_group, user) ⇒ RejectGroupInvitation

Public: Initializes the command.

user_group - the UserGroup where the user has been invited user - the User that has been invited


11
12
13
14
# File 'decidim-core/app/commands/decidim/reject_group_invitation.rb', line 11

def initialize(user_group, user)
  @user_group = user_group
  @user = user
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if we couldn't proceed.

Returns nothing.


22
23
24
25
26
27
28
# File 'decidim-core/app/commands/decidim/reject_group_invitation.rb', line 22

def call
  return broadcast(:invalid) if membership.blank?

  reject_invitation

  broadcast(:ok)
end