Class: Decidim::DecidimAwesome::Admin::DestroyScopedAdmin
- Inherits:
-
Command
- Object
- Command
- Command
- Decidim::DecidimAwesome::Admin::DestroyScopedAdmin
- Includes:
- NeedsConstraintHelpers
- Defined in:
- app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb
Instance Method Summary collapse
-
#call ⇒ Object
Executes the command.
-
#initialize(key, organization) ⇒ DestroyScopedAdmin
constructor
Public: Initializes the command.
Constructor Details
#initialize(key, organization) ⇒ DestroyScopedAdmin
Public: Initializes the command.
key - the key to destroy inside scoped_admins organization
12 13 14 15 16 |
# File 'app/commands/decidim/decidim_awesome/admin/destroy_scoped_admin.rb', line 12 def initialize(key, organization) @ident = key @organization = organization @config_var = :scoped_admins 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_scoped_admin.rb', line 24 def call return broadcast(:invalid, "Not a hash") unless find_var&.value.is_a? Hash return broadcast(:invalid, "#{ident} key invalid") unless find_var.value.has_key?(ident) destroy_hash_ident! broadcast(:ok, ident) rescue StandardError => e broadcast(:invalid, e.) end |