Class: Decidim::DecidimAwesome::Admin::DestroyMenuHack
- Includes:
- NeedsConstraintHelpers
- Defined in:
- app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(item, menu_name, organization) ⇒ DestroyMenuHack
constructor
Public: Initializes the command.
Constructor Details
#initialize(item, menu_name, organization) ⇒ DestroyMenuHack
Public: Initializes the command.
item - the menu item to destroy organization
12 13 14 15 16 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb', line 12 def initialize(item, , organization) @item = item @organization = organization @config_var = 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.
24 25 26 27 28 29 30 31 32 33 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_menu_hack.rb', line 24 def call return broadcast(:invalid) unless url_exists? find_var.value&.reject! { |i| i["url"] == item.url } find_var.save! broadcast(:ok, @item) rescue StandardError => e broadcast(:invalid, e.) end |