Class: Decidim::UnsubscribeSettings

Inherits:
Command
  • Object
show all
Defined in:
app/commands/decidim/unsubscribe_settings.rb

Overview

This command unsubscribes user from newsletter.

Instance Method Summary collapse

Methods inherited from Command

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

Constructor Details

#initialize(user) ⇒ UnsubscribeSettings

unsubscribe user from newsletter.

user - The user to be updated. newsletter_notifications_at - to be nil



10
11
12
# File 'app/commands/decidim/unsubscribe_settings.rb', line 10

def initialize(user)
  @user = user
end

Dynamic Method Handling

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

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
# File 'app/commands/decidim/unsubscribe_settings.rb', line 14

def call
  return broadcast(:invalid) unless @user.newsletter_notifications_at?

  update_settings
  @user.save!

  broadcast(:ok, @user)
end