Class: Decidim::Voca::Organization::UpdateColorCommand
- Inherits:
-
OrganizationCommand
- Object
- Command
- OrganizationCommand
- Decidim::Voca::Organization::UpdateColorCommand
- Defined in:
- app/commands/decidim/voca/organization/update_color_command.rb
Instance Attribute Summary collapse
-
#color_settings ⇒ Object
readonly
Returns the value of attribute color_settings.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(color_settings) ⇒ UpdateColorCommand
constructor
A new instance of UpdateColorCommand.
Methods inherited from OrganizationCommand
#command_name, command_name, #organization
Constructor Details
#initialize(color_settings) ⇒ UpdateColorCommand
Returns a new instance of UpdateColorCommand.
6 7 8 |
# File 'app/commands/decidim/voca/organization/update_color_command.rb', line 6 def initialize(color_settings) @color_settings = with_defaults(color_settings.to_h.with_indifferent_access) end |
Instance Attribute Details
#color_settings ⇒ Object (readonly)
Returns the value of attribute color_settings.
5 6 7 |
# File 'app/commands/decidim/voca/organization/update_color_command.rb', line 5 def color_settings @color_settings end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/commands/decidim/voca/organization/update_color_command.rb', line 10 def call organization.update!( colors: (organization.colors || []).merge(color_settings.delete_if { |_k, v| v.blank? }) ) broadcast(:ok) rescue e Rails.logger.error(e) broadcast(:fail) end |