Class: Pageflow::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Pageflow::Page
- Defined in:
- app/models/pageflow/page.rb
Instance Attribute Summary collapse
-
#is_first ⇒ Object
Returns the value of attribute is_first.
Instance Method Summary collapse
- #configuration ⇒ Object
- #configuration=(value) ⇒ Object
- #copy_to(chapter) ⇒ Object
- #ensure_perma_id ⇒ Object
- #thumbnail ⇒ Object
- #thumbnail_definition ⇒ Object
- #title ⇒ Object
Instance Attribute Details
#is_first ⇒ Object
Returns the value of attribute is_first.
5 6 7 |
# File 'app/models/pageflow/page.rb', line 5 def is_first @is_first end |
Instance Method Details
#configuration ⇒ Object
48 49 50 |
# File 'app/models/pageflow/page.rb', line 48 def configuration super || {} end |
#configuration=(value) ⇒ Object
52 53 54 55 |
# File 'app/models/pageflow/page.rb', line 52 def configuration=(value) self. = value['display_in_navigation'] super end |
#copy_to(chapter) ⇒ Object
57 58 59 |
# File 'app/models/pageflow/page.rb', line 57 def copy_to(chapter) chapter.pages << dup end |
#ensure_perma_id ⇒ Object
61 62 63 |
# File 'app/models/pageflow/page.rb', line 61 def ensure_perma_id self.perma_id ||= (Page.maximum(:perma_id) || 0) + 1 end |
#thumbnail ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/models/pageflow/page.rb', line 19 def thumbnail model_name, , property, model_class = thumbnail_definition begin model_name.to_s.camelcase.constantize.find(configuration[property]).send() rescue ActiveRecord::RecordNotFound ImageFile.new. end end |
#thumbnail_definition ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/models/pageflow/page.rb', line 29 def thumbnail_definition # TODO: this has to be refactored to be page type agnostic if template == 'video' || template == 'background_video' if configuration['poster_image_id'].present? ['pageflow/image_file', :processed_attachment, 'poster_image_id', 'image_file'] else ['pageflow/video_file', :poster, 'video_file_id', 'video_file'] end else if configuration['thumbnail_image_id'].present? ['pageflow/image_file', :processed_attachment, 'thumbnail_image_id', 'image_file'] elsif configuration['after_image_id'].present? ['pageflow/image_file', :processed_attachment, 'after_image_id','image_file'] else ['pageflow/image_file', :processed_attachment, 'background_image_id', 'image_file'] end end end |
#title ⇒ Object
15 16 17 |
# File 'app/models/pageflow/page.rb', line 15 def title configuration['title'].presence || configuration['additional_title'] end |