Class: Decidim::Elections::Admin::UpdateQuestions
- Defined in:
- decidim-elections/app/commands/decidim/elections/admin/update_questions.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form, election) ⇒ UpdateQuestions
constructor
A new instance of UpdateQuestions.
Methods inherited from Command
call, #evaluate, #method_missing, #respond_to_missing?, #transaction, #with_events
Constructor Details
#initialize(form, election) ⇒ UpdateQuestions
Returns a new instance of UpdateQuestions.
7 8 9 10 |
# File 'decidim-elections/app/commands/decidim/elections/admin/update_questions.rb', line 7 def initialize(form, election) @form = form @election = election end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Decidim::Command
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'decidim-elections/app/commands/decidim/elections/admin/update_questions.rb', line 12 def call return broadcast(:invalid) if @form.invalid? current_position = @election.questions.count || 0 @form.questions.each_with_index do |question_form, index| if question_form.deleted? delete_question(question_form) else update_question(question_form, index + current_position) end end broadcast(:ok) end |