Class: Pageflow::PublishedEntry

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion
Defined in:
app/models/pageflow/published_entry.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry, revision = nil) ⇒ PublishedEntry

Returns a new instance of PublishedEntry.



15
16
17
18
19
# File 'app/models/pageflow/published_entry.rb', line 15

def initialize(entry, revision = nil)
  @entry = entry
  @revision = revision || entry.published_revision
  @custom_revision = !!revision
end

Instance Attribute Details

#entryObject (readonly)

Returns the value of attribute entry.



6
7
8
# File 'app/models/pageflow/published_entry.rb', line 6

def entry
  @entry
end

#revisionObject (readonly)

Returns the value of attribute revision.



6
7
8
# File 'app/models/pageflow/published_entry.rb', line 6

def revision
  @revision
end

Class Method Details

.find(id, scope = Entry) ⇒ Object



33
34
35
# File 'app/models/pageflow/published_entry.rb', line 33

def self.find(id, scope = Entry)
  PublishedEntry.new(scope.published.find(id))
end

Instance Method Details

#cache_keyObject



37
38
39
# File 'app/models/pageflow/published_entry.rb', line 37

def cache_key
  "#{self.class.model_name.cache_key}/#{entry.cache_key}-#{revision.cache_key}"
end

#home_buttonObject



41
42
43
# File 'app/models/pageflow/published_entry.rb', line 41

def home_button
  HomeButton.new(revision, theming)
end

#stylesheet_cache_keyObject



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

def stylesheet_cache_key
  revision.cache_key
end

#stylesheet_modelObject



21
22
23
# File 'app/models/pageflow/published_entry.rb', line 21

def stylesheet_model
  custom_revision? ? revision : entry
end

#thumbnailObject



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

def thumbnail
  pages.first.try(:thumbnail) || ImageFile.new.processed_attachment
end