Class: Wizardry::Pages::QuestionPage

Inherits:
Page
  • Object
show all
Defined in:
lib/wizardry/pages/question_page.rb

Instance Attribute Summary collapse

Attributes inherited from Page

#pages

Instance Method Summary collapse

Methods inherited from Page

#after_update!, #before_edit!, #before_update!, #branch!, #branch?

Constructor Details

#initialize(name, questions:, next_pages: {}, pages: [], title: nil, before_edit: nil, before_update: nil, after_update: nil) ⇒ QuestionPage

Returns a new instance of QuestionPage.



6
7
8
9
10
11
12
13
14
15
# File 'lib/wizardry/pages/question_page.rb', line 6

def initialize(name, questions:, next_pages: {}, pages: [], title: nil, before_edit: nil, before_update: nil, after_update: nil)
  Rails.logger.debug("🧙 Adding page '#{name}' with #{questions&.size || 'no'} questions")

  @name       = name
  @title      = title || name.capitalize
  @questions  = questions
  @next_pages = next_pages

  super(pages: pages, before_edit: before_edit, before_update: before_update, after_update: after_update)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/wizardry/pages/question_page.rb', line 4

def name
  @name
end

#next_pagesObject

Returns the value of attribute next_pages.



4
5
6
# File 'lib/wizardry/pages/question_page.rb', line 4

def next_pages
  @next_pages
end

#questionsObject

Returns the value of attribute questions.



4
5
6
# File 'lib/wizardry/pages/question_page.rb', line 4

def questions
  @questions
end

#titleObject

Returns the value of attribute title.



4
5
6
# File 'lib/wizardry/pages/question_page.rb', line 4

def title
  @title
end

Instance Method Details

#question_namesObject



17
18
19
# File 'lib/wizardry/pages/question_page.rb', line 17

def question_names
  @questions.map(&:name)
end