Class: Decidim::DecidimAwesome::Admin::DestroyCustomRedirect
- Inherits:
-
Command
- Object
- Command
- Command
- Decidim::DecidimAwesome::Admin::DestroyCustomRedirect
- Defined in:
- app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(item, organization) ⇒ DestroyCustomRedirect
constructor
Public: Initializes the command.
Constructor Details
#initialize(item, organization) ⇒ DestroyCustomRedirect
Public: Initializes the command.
item - the redirections item to destroy organization
11 12 13 14 15 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb', line 11 def initialize(item, organization) @item = item @organization = organization @redirections = AwesomeConfig.find_by(var: :custom_redirects, organization:) end |
Instance Method Details
#call ⇒ Object
Executes the command. Broadcasts these events:
-
:ok when everything is valid.
-
:invalid if we couldn’t proceed.
Returns nothing.
23 24 25 26 27 28 29 30 31 32 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_custom_redirect.rb', line 23 def call return broadcast(:invalid) unless url_exists? redirections.value&.except!(item.origin) redirections.save! broadcast(:ok, @item) rescue StandardError => e broadcast(:invalid, e.) end |