Class: Decidim::Admin::ParticipatorySpace::UpdateAdmin
- Inherits:
-
Command
- Object
- Command
- Decidim::Admin::ParticipatorySpace::UpdateAdmin
- Defined in:
- app/commands/decidim/admin/participatory_space/update_admin.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(form, user_role, options = {}) ⇒ UpdateAdmin
constructor
Public: Initializes the command.
Constructor Details
#initialize(form, user_role, options = {}) ⇒ UpdateAdmin
Public: Initializes the command.
form - A form object with the params. user_role - The UserRole to update options: a hash with at least two mandatory keys, event_class and event
-
event_class - The event class to be used when notifying the user
-
event - The event name to be used when notifying the user
14 15 16 17 18 19 |
# File 'app/commands/decidim/admin/participatory_space/update_admin.rb', line 14 def initialize(form, user_role, = {}) @form = form @user_role = user_role @event_class = .delete(:event_class) @event = .delete(:event) end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if the form was not valid and we could not proceed.
Returns nothing.
27 28 29 30 31 32 33 |
# File 'app/commands/decidim/admin/participatory_space/update_admin.rb', line 27 def call return broadcast(:invalid) if form.invalid? return broadcast(:invalid) unless user_role update_role! broadcast(:ok) end |