Class: Decidim::Forms::Admin::QuestionnaireAnswerPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Forms::Admin::QuestionnaireAnswerPresenter
- Includes:
- TranslatableAttributes
- Defined in:
- app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb
Overview
Presenter for questionnaire answer
Instance Method Summary collapse
Instance Method Details
#answer ⇒ Object
14 15 16 |
# File 'app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb', line 14 def answer __getobj__.fetch(:answer) end |
#attachments ⇒ Object
45 46 47 48 49 |
# File 'app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb', line 45 def content_tag(:ul) do safe_join(answer..map { |a| (a) }) end end |
#body ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb', line 26 def body return answer.body if answer.body.present? return if answer..any? return "-" if answer.choices.empty? choices = answer.choices.map do |choice| { answer_option_body: choice.try(:answer_option).try(:translated_body), choice_body: body_or_custom_body(choice) } end return choice(choices.first) if answer.question.question_type == "single_option" content_tag(:ul) do safe_join(choices.map { |c| choice(c) }) end end |
#question ⇒ Object
22 23 24 |
# File 'app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb', line 22 def question translated_attribute(answer.question.body) end |
#view_context ⇒ Object
18 19 20 |
# File 'app/presenters/decidim/forms/admin/questionnaire_answer_presenter.rb', line 18 def view_context __getobj__.fetch(:view_context, ActionController::Base.new.view_context) end |