Class: Decidim::UpdateNotificationsSettings

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

Overview

This command updates the user’s notifications settings.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(form) ⇒ UpdateNotificationsSettings

Updates a user’s notifications settings.

form - The form with the data.



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

def initialize(form)
  @form = form
end

Dynamic Method Handling

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

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
# File 'decidim-core/app/commands/decidim/update_notifications_settings.rb', line 15

def call
  return broadcast(:invalid) unless @form.valid?

  update_notifications_settings
  current_user.save!

  broadcast(:ok, current_user)
end