Class: Decidim::UnsubscribeSettings

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

Overview

This command unsubscribes user from newsletter.

Instance Method Summary collapse

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 'decidim-core/app/commands/decidim/unsubscribe_settings.rb', line 10

def initialize(user)
  @user = user
end

Instance Method Details

#callObject


14
15
16
17
18
19
20
21
# File 'decidim-core/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