Class: Pageflow::ChapterScaffold

Inherits:
Object
  • Object
show all
Defined in:
app/models/pageflow/chapter_scaffold.rb

Overview

rubocop:todo Style/Documentation

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chapter, options) ⇒ ChapterScaffold

Returns a new instance of ChapterScaffold.



3
4
5
6
# File 'app/models/pageflow/chapter_scaffold.rb', line 3

def initialize(chapter, options)
  @chapter = chapter
  @options = options
end

Class Method Details

.build(storyline, attributes, options) ⇒ Object



27
28
29
# File 'app/models/pageflow/chapter_scaffold.rb', line 27

def self.build(storyline, attributes, options)
  new(storyline.chapters.build(attributes), options).build
end

Instance Method Details

#as_json(_ = {}) ⇒ Object



16
17
18
19
20
21
# File 'app/models/pageflow/chapter_scaffold.rb', line 16

def as_json(_ = {})
  {
    chapter: @chapter,
    page: @page
  }
end

#buildObject



10
11
12
13
14
# File 'app/models/pageflow/chapter_scaffold.rb', line 10

def build
  @page = @chapter.pages.build(template: 'background_image') if @options[:depth] == 'page'

  self
end

#to_modelObject



23
24
25
# File 'app/models/pageflow/chapter_scaffold.rb', line 23

def to_model
  @chapter
end