Class: Decidim::Voca::Organization::UpdateSmtpCommand

Inherits:
OrganizationCommand show all
Defined in:
app/commands/decidim/voca/organization/update_smtp_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OrganizationCommand

#command_name, command_name, #organization

Constructor Details

#initialize(smtp_settings) ⇒ UpdateSmtpCommand

Returns a new instance of UpdateSmtpCommand.



6
7
8
# File 'app/commands/decidim/voca/organization/update_smtp_command.rb', line 6

def initialize(smtp_settings)
  @smtp_settings = transform_settings(smtp_settings.to_h.with_indifferent_access)
end

Instance Attribute Details

#smtp_settingsObject (readonly)

Returns the value of attribute smtp_settings.



5
6
7
# File 'app/commands/decidim/voca/organization/update_smtp_command.rb', line 5

def smtp_settings
  @smtp_settings
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
# File 'app/commands/decidim/voca/organization/update_smtp_command.rb', line 10

def call
  organization.update!(
    smtp_settings: smtp_settings.delete_if { |_k, v| v.blank? }
  )
  broadcast(:ok)
rescue => e
  Rails.logger.error(e)
  broadcast(:fail)
end