Class: Pageflow::ChapterScaffold

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

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



29
30
31
# File 'app/models/pageflow/chapter_scaffold.rb', line 29

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

Instance Method Details

#as_json(_ = {}) ⇒ Object



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

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

#buildObject



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

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

  self
end

#to_modelObject



25
26
27
# File 'app/models/pageflow/chapter_scaffold.rb', line 25

def to_model
  @chapter
end