Class: Pageflow::PublishedEntry
- Inherits:
-
Object
- Object
- Pageflow::PublishedEntry
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion
- Defined in:
- app/models/pageflow/published_entry.rb
Instance Attribute Summary collapse
-
#entry ⇒ Object
readonly
Returns the value of attribute entry.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
-
#share_target ⇒ Object
Returns the value of attribute share_target.
Class Method Summary collapse
Instance Method Summary collapse
- #cache_key ⇒ Object
- #cache_version ⇒ Object
- #home_button ⇒ Object
-
#initialize(entry, revision = nil) ⇒ PublishedEntry
constructor
A new instance of PublishedEntry.
- #overview_button ⇒ Object
- #page_thumbnail_file(page) ⇒ Object
- #resolve_widgets(options = {}) ⇒ Object
- #stylesheet_cache_key ⇒ Object
- #stylesheet_model ⇒ Object
- #thumbnail_file ⇒ Object
- #thumbnail_url(*args) ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(entry, revision = nil) ⇒ PublishedEntry
Returns a new instance of PublishedEntry.
36 37 38 39 40 |
# File 'app/models/pageflow/published_entry.rb', line 36 def initialize(entry, revision = nil) @entry = entry @revision = revision || entry.published_revision @custom_revision = !!revision end |
Instance Attribute Details
#entry ⇒ Object (readonly)
Returns the value of attribute entry.
6 7 8 |
# File 'app/models/pageflow/published_entry.rb', line 6 def entry @entry end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
6 7 8 |
# File 'app/models/pageflow/published_entry.rb', line 6 def revision @revision end |
#share_target ⇒ Object
Returns the value of attribute share_target.
7 8 9 |
# File 'app/models/pageflow/published_entry.rb', line 7 def share_target @share_target end |
Class Method Details
.find(id, scope = Entry) ⇒ Object
70 71 72 |
# File 'app/models/pageflow/published_entry.rb', line 70 def self.find(id, scope = Entry) PublishedEntry.new(scope.published.find(id)) end |
Instance Method Details
#cache_key ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'app/models/pageflow/published_entry.rb', line 74 def cache_key [ self.class.model_name.cache_key, entry.cache_key, revision.cache_key, theming.cache_key ].compact.join('-') end |
#cache_version ⇒ Object
83 84 85 86 87 88 89 |
# File 'app/models/pageflow/published_entry.rb', line 83 def cache_version [ entry.cache_version, revision.cache_version, theming.cache_version ].compact.join('-').presence end |
#home_button ⇒ Object
91 92 93 |
# File 'app/models/pageflow/published_entry.rb', line 91 def HomeButton.new(revision, theming) end |
#overview_button ⇒ Object
95 96 97 |
# File 'app/models/pageflow/published_entry.rb', line 95 def OverviewButton.new(revision) end |
#page_thumbnail_file(page) ⇒ Object
64 65 66 67 68 |
# File 'app/models/pageflow/published_entry.rb', line 64 def page_thumbnail_file(page) return unless page.present? ThumbnailFileResolver.new(self, page.page_type.thumbnail_candidates, page.configuration) .find_thumbnail end |
#resolve_widgets(options = {}) ⇒ Object
99 100 101 |
# File 'app/models/pageflow/published_entry.rb', line 99 def ( = {}) .resolve(Pageflow.config_for(entry), ) end |
#stylesheet_cache_key ⇒ Object
50 51 52 |
# File 'app/models/pageflow/published_entry.rb', line 50 def stylesheet_cache_key revision.cache_key_with_version end |
#stylesheet_model ⇒ Object
46 47 48 |
# File 'app/models/pageflow/published_entry.rb', line 46 def stylesheet_model custom_revision? ? revision : entry end |
#thumbnail_file ⇒ Object
58 59 60 61 62 |
# File 'app/models/pageflow/published_entry.rb', line 58 def thumbnail_file share_image_file || page_thumbnail_file(pages.first) || PositionedFile.null end |
#thumbnail_url(*args) ⇒ Object
54 55 56 |
# File 'app/models/pageflow/published_entry.rb', line 54 def thumbnail_url(*args) thumbnail_file.thumbnail_url(*args) end |
#title ⇒ Object
42 43 44 |
# File 'app/models/pageflow/published_entry.rb', line 42 def title revision.title.presence || entry.title end |