Class: Decidim::DecidimAwesome::Admin::CreateProposalCustomField

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

Instance Method Summary collapse

Constructor Details

#initialize(organization, config_var = :proposal_custom_fields) ⇒ CreateProposalCustomField

Public: Initializes the command.



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

def initialize(organization, config_var = :proposal_custom_fields)
  @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.



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

def call
  create_hash_config!(default_definition)

  create_constraint_never!

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