Class: Decidim::Toggle::UpdateNameCommand
- Inherits:
-
Command
- Object
- Command
- Decidim::Toggle::UpdateNameCommand
- Defined in:
- app/commands/decidim/toggle/update_name_command.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(organization, form) ⇒ UpdateNameCommand
constructor
A new instance of UpdateNameCommand.
Constructor Details
#initialize(organization, form) ⇒ UpdateNameCommand
Returns a new instance of UpdateNameCommand.
6 7 8 9 |
# File 'app/commands/decidim/toggle/update_name_command.rb', line 6 def initialize(organization, form) @organization = organization @form = form end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/commands/decidim/toggle/update_name_command.rb', line 11 def call return broadcast(:invalid) if form.invalid? transaction do organization.name = form.name organization.host = form.host organization.secondary_hosts = form.clean_secondary_hosts organization.save! end broadcast(:ok) rescue ActiveRecord::RecordInvalid broadcast(:invalid) end |