Class: Wizardry::Pages::Page

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pages: [], before_edit: nil, before_update: nil, after_update: nil) ⇒ Page

Returns a new instance of Page.



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

def initialize(pages: [], before_edit: nil, before_update: nil, after_update: nil)
  @pages  = pages
  @branch = false

  # callbacks
  @before_edit   = before_edit
  @before_update = before_update
  @after_update  = after_update
end

Instance Attribute Details

#pagesObject (readonly)

Returns the value of attribute pages.



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

def pages
  @pages
end

Instance Method Details

#after_update!(object) ⇒ Object



44
45
46
47
48
# File 'lib/wizardry/pages/page.rb', line 44

def after_update!(object)
  return unless @after_update

  @after_update.call(object)
end

#before_edit!(object) ⇒ Object



32
33
34
35
36
# File 'lib/wizardry/pages/page.rb', line 32

def before_edit!(object)
  return unless @before_edit

  @before_edit.call(object)
end

#before_update!(object) ⇒ Object



38
39
40
41
42
# File 'lib/wizardry/pages/page.rb', line 38

def before_update!(object)
  return unless @before_update

  @before_update.call(object)
end

#branch!Object



16
17
18
# File 'lib/wizardry/pages/page.rb', line 16

def branch!
  @branch = true
end

#branch?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/wizardry/pages/page.rb', line 20

def branch?
  @branch
end

#next_pagesObject



28
29
30
# File 'lib/wizardry/pages/page.rb', line 28

def next_pages
  []
end

#questionsObject



24
25
26
# File 'lib/wizardry/pages/page.rb', line 24

def questions
  []
end