Class: Decidim::SpamSignal::Admin::UpdateRuleCommand
- Inherits:
-
Command
- Object
- Rectify::Command
- Command
- Decidim::SpamSignal::Admin::UpdateRuleCommand
- Defined in:
- app/commands/decidim/spam_signal/admin/update_rule_command.rb
Instance Attribute Summary collapse
-
#current_config ⇒ Object
readonly
Returns the value of attribute current_config.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#settings_repo ⇒ Object
readonly
Returns the value of attribute settings_repo.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(config, settings_repo, form, id) ⇒ UpdateRuleCommand
constructor
A new instance of UpdateRuleCommand.
Constructor Details
#initialize(config, settings_repo, form, id) ⇒ UpdateRuleCommand
Returns a new instance of UpdateRuleCommand.
12 13 14 15 16 17 18 19 |
# File 'app/commands/decidim/spam_signal/admin/update_rule_command.rb', line 12 def initialize(config, settings_repo, form, id) @current_config = config @settings_repo = settings_repo @form = form @id = id raise ArgumentError, "missing current_config" unless current_config raise ArgumentError, "missing settings_repo" unless settings_repo end |
Instance Attribute Details
#current_config ⇒ Object (readonly)
Returns the value of attribute current_config.
7 8 9 |
# File 'app/commands/decidim/spam_signal/admin/update_rule_command.rb', line 7 def current_config @current_config end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
7 8 9 |
# File 'app/commands/decidim/spam_signal/admin/update_rule_command.rb', line 7 def form @form end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'app/commands/decidim/spam_signal/admin/update_rule_command.rb', line 7 def id @id end |
#settings_repo ⇒ Object (readonly)
Returns the value of attribute settings_repo.
7 8 9 |
# File 'app/commands/decidim/spam_signal/admin/update_rule_command.rb', line 7 def settings_repo @settings_repo end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/commands/decidim/spam_signal/admin/update_rule_command.rb', line 21 def call return broadcast(:invalid) if form.invalid? begin rule = {} rule["#{id}"] = attributes rule["#{id}"]["handler_name"] = form.handler_name settings_repo.set_rule(rule) current_config.save_settings broadcast(:ok, settings_repo) rescue StandardError => e broadcast(:invalid, e.) end end |