Module: Decidim::Consultations::NeedsQuestion::InstanceMethods
- Defined in:
- app/controllers/concerns/decidim/consultations/needs_question.rb
Instance Method Summary collapse
-
#current_consultation ⇒ Object
Public: Finds the current Consultation given this controller’s context.
-
#current_question ⇒ Object
(also: #current_participatory_space)
Public: Finds the current Question given this controller’s context.
-
#next_published_question ⇒ Object
same as next_question but for published questions only.
-
#next_question ⇒ Object
Public: Finds the next Question in the Array of questions associated to the current_question’s consultation.
-
#previous_published_question ⇒ Object
same as previous_question but for published questions only.
-
#previous_question ⇒ Object
Public: Finds the previous Question in the Array of questions associated to the current_question’s consultation.
Instance Method Details
#current_consultation ⇒ Object
Public: Finds the current Consultation given this controller’s context.
Returns the current Consultation.
76 77 78 |
# File 'app/controllers/concerns/decidim/consultations/needs_question.rb', line 76 def current_consultation @current_consultation ||= current_question&.consultation || detect_consultation end |
#current_question ⇒ Object Also known as: current_participatory_space
Public: Finds the current Question given this controller’s context.
Returns the current Question.
34 35 36 |
# File 'app/controllers/concerns/decidim/consultations/needs_question.rb', line 34 def current_question @current_question ||= detect_question end |
#next_published_question ⇒ Object
same as next_question but for published questions only
59 60 61 62 63 |
# File 'app/controllers/concerns/decidim/consultations/needs_question.rb', line 59 def next_published_question return nil if current_published_question_index + 1 >= current_consultation_published_questions.size current_consultation_published_questions.at(current_published_question_index + 1) end |
#next_question ⇒ Object
Public: Finds the next Question in the Array of questions associated to the current_question’s consultation.
Returns the next Question in the Array or nil if out of bounds.
52 53 54 55 56 |
# File 'app/controllers/concerns/decidim/consultations/needs_question.rb', line 52 def next_question return nil if current_question_index + 1 >= current_consultation_questions.size current_consultation_questions.at(current_question_index + 1) end |
#previous_published_question ⇒ Object
same as previous_question but for published questions only
66 67 68 69 70 |
# File 'app/controllers/concerns/decidim/consultations/needs_question.rb', line 66 def previous_published_question return nil if (current_published_question_index - 1).negative? current_consultation_published_questions.at(current_published_question_index - 1) end |
#previous_question ⇒ Object
Public: Finds the previous Question in the Array of questions associated to the current_question’s consultation.
Returns the previous Question in the Array or nil if out of bounds.
42 43 44 45 46 |
# File 'app/controllers/concerns/decidim/consultations/needs_question.rb', line 42 def previous_question return nil if (current_question_index - 1).negative? current_consultation_questions.at(current_question_index - 1) end |