Class: Decidim::DecidimAwesome::Admin::CreateAuthorizationGroup

Inherits:
Command
  • Object
show all
Includes:
NeedsConstraintHelpers
Defined in:
app/commands/decidim/decidim_awesome/admin/create_authorization_group.rb

Instance Method Summary collapse

Constructor Details

#initialize(organization, config_var = :force_authorizations) ⇒ CreateAuthorizationGroup

Public: Initializes the command.



10
11
12
13
# File 'app/commands/decidim/decidim_awesome/admin/create_authorization_group.rb', line 10

def initialize(organization, config_var = :force_authorizations)
  @organization = organization
  @config_var = config_var
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.

  • :invalid if we couldn’t proceed.

Returns nothing.



21
22
23
24
25
26
27
28
29
# File 'app/commands/decidim/decidim_awesome/admin/create_authorization_group.rb', line 21

def call
  create_hash_config!(attributes)

  create_constraint_never!

  broadcast(:ok, ident)
rescue StandardError => e
  broadcast(:invalid, e.message)
end