Class: Pageflow::ChapterScaffold
- Inherits:
-
Object
- Object
- Pageflow::ChapterScaffold
- Defined in:
- app/models/pageflow/chapter_scaffold.rb
Class Method Summary collapse
Instance Method Summary collapse
- #as_json(_ = {}) ⇒ Object
- #build ⇒ Object
-
#initialize(chapter, options) ⇒ ChapterScaffold
constructor
A new instance of ChapterScaffold.
- #to_model ⇒ Object
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, ) @chapter = chapter @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, ) new(storyline.chapters.build(attributes), ).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 |
#build ⇒ Object
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_model ⇒ Object
25 26 27 |
# File 'app/models/pageflow/chapter_scaffold.rb', line 25 def to_model @chapter end |