Class: Decidim::Elections::Admin::RemoveTrusteeFromParticipatorySpace

Inherits:
Command
  • Object
show all
Defined in:
decidim-elections/app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb

Overview

This command is executed when the admin user removes a trustee from a participatory space from the admin panel.

Instance Method Summary collapse

Methods inherited from Command

call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events

Constructor Details

#initialize(trustee_participatory_space) ⇒ RemoveTrusteeFromParticipatorySpace

Public: Initializes the command.

trustee_participatory_space - A trustee_participatory_space



12
13
14
# File 'decidim-elections/app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb', line 12

def initialize(trustee_participatory_space)
  @trustee_participatory_space = trustee_participatory_space
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Decidim::Command

Instance Method Details

#callObject

Removes the trustee from participatory space if valid.

Broadcasts :ok if successful, :invalid otherwise.



19
20
21
22
23
24
25
# File 'decidim-elections/app/commands/decidim/elections/admin/remove_trustee_from_participatory_space.rb', line 19

def call
  return broadcast(:invalid) if !trustee_participatory_space || trustee_participatory_space.trustee.elections.any?

  remove_trustee_from_participatory_space!

  broadcast(:ok, trustee_participatory_space.trustee)
end