Class: Decidim::DecidimAwesome::Admin::CreateAwesomeAuthorizationGroup

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

Instance Method Summary collapse

Constructor Details

#initialize(form) ⇒ CreateAwesomeAuthorizationGroup

Public: Initializes the command.

form - The form object with the authorization group data



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

def initialize(form)
  @form = form
end

Instance Method Details

#callObject

Executes the command. Broadcasts these events:

  • :ok when everything is valid.
  • :invalid if we couldn't proceed.

Returns nothing.



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

def call
  return broadcast(:invalid, form.errors.full_messages.join("; ")) if form.invalid?

  create_authorization_group!

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