Class: MetadataPresenter::PageAnswersPresenter
- Inherits:
-
Object
- Object
- MetadataPresenter::PageAnswersPresenter
- Defined in:
- app/presenters/metadata_presenter/page_answers_presenter.rb
Instance Attribute Summary collapse
-
#answers ⇒ Object
readonly
Returns the value of attribute answers.
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Class Method Summary collapse
Instance Method Summary collapse
- #answer ⇒ Object
-
#initialize(view:, component:, page:, answers:) ⇒ PageAnswersPresenter
constructor
A new instance of PageAnswersPresenter.
Constructor Details
#initialize(view:, component:, page:, answers:) ⇒ PageAnswersPresenter
Returns a new instance of PageAnswersPresenter.
20 21 22 23 24 25 26 27 |
# File 'app/presenters/metadata_presenter/page_answers_presenter.rb', line 20 def initialize(view:, component:, page:, answers:) @view = view @component = component @page = page @answers = answers @page_answers = PageAnswers.new(page, answers) end |
Instance Attribute Details
#answers ⇒ Object (readonly)
Returns the value of attribute answers.
16 17 18 |
# File 'app/presenters/metadata_presenter/page_answers_presenter.rb', line 16 def answers @answers end |
#component ⇒ Object (readonly)
Returns the value of attribute component.
16 17 18 |
# File 'app/presenters/metadata_presenter/page_answers_presenter.rb', line 16 def component @component end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
16 17 18 |
# File 'app/presenters/metadata_presenter/page_answers_presenter.rb', line 16 def page @page end |
#view ⇒ Object (readonly)
Returns the value of attribute view.
16 17 18 |
# File 'app/presenters/metadata_presenter/page_answers_presenter.rb', line 16 def view @view end |
Class Method Details
.map(view:, pages:, answers:) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/presenters/metadata_presenter/page_answers_presenter.rb', line 3 def self.map(view:, pages:, answers:) pages.map do |page| Array(page.components).map do |component| new( view: view, component: component, page: page, answers: answers ) end end.flatten end |
Instance Method Details
#answer ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'app/presenters/metadata_presenter/page_answers_presenter.rb', line 29 def answer value = @page_answers.send(component.id) return '' if value.blank? if self.class.private_method_defined?(component.type.to_sym) send(component.type.to_sym, value) else value end end |