Class: Decidim::RemoveUserFromGroup
- Defined in:
- app/commands/decidim/remove_user_from_group.rb
Overview
A command with all the business logic to remove a user from a group.
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(membership, user_group) ⇒ RemoveUserFromGroup
constructor
Public: Initializes the command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction
Constructor Details
#initialize(membership, user_group) ⇒ RemoveUserFromGroup
Public: Initializes the command.
membership - the UserGroupMembership to be accepted.
9 10 11 12 |
# File 'app/commands/decidim/remove_user_from_group.rb', line 9 def initialize(membership, user_group) @membership = membership @user_group = user_group end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if we couldn’t proceed.
Returns nothing.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/commands/decidim/remove_user_from_group.rb', line 20 def call return broadcast(:invalid) if membership.blank? return broadcast(:invalid) if membership.user_group != user_group transaction do remove_membership send_notification end broadcast(:ok) end |