Class: Decidim::Templates::Admin::CreateProposalAnswerTemplate
- Defined in:
- decidim-templates/app/commands/decidim/templates/admin/create_proposal_answer_template.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form) ⇒ CreateProposalAnswerTemplate
constructor
Initializes the command.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(form) ⇒ CreateProposalAnswerTemplate
Initializes the command.
form - The source for this ProposalAnswerTemplate.
10 11 12 |
# File 'decidim-templates/app/commands/decidim/templates/admin/create_proposal_answer_template.rb', line 10 def initialize(form) @form = form end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'decidim-templates/app/commands/decidim/templates/admin/create_proposal_answer_template.rb', line 14 def call return broadcast(:component_selected) if @form.select_component return broadcast(:invalid) unless @form.valid? @template = Decidim.traceability.create!( Template, @form.current_user, name: @form.name, description: @form.description, organization: @form.current_organization, field_values: { proposal_state_id: @form.proposal_state_id }, target: :proposal_answer ) @template.update!(templatable: identify_templateable_resource) broadcast(:ok, @template) end |