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.



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

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

#share_targetObject

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



57
58
59
# File 'app/models/pageflow/published_entry.rb', line 57

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

Instance Method Details

#cache_keyObject



61
62
63
64
# File 'app/models/pageflow/published_entry.rb', line 61

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

#home_buttonObject



66
67
68
# File 'app/models/pageflow/published_entry.rb', line 66

def home_button
  HomeButton.new(revision, theming)
end

#overview_buttonObject



70
71
72
# File 'app/models/pageflow/published_entry.rb', line 70

def overview_button
  OverviewButton.new(revision, theming)
end

#resolve_widgets(options = {}) ⇒ Object



74
75
76
# File 'app/models/pageflow/published_entry.rb', line 74

def resolve_widgets(options = {})
  widgets.resolve(Pageflow.config_for(entry), options)
end

#stylesheet_cache_keyObject



43
44
45
# File 'app/models/pageflow/published_entry.rb', line 43

def stylesheet_cache_key
  revision.cache_key
end

#stylesheet_modelObject



39
40
41
# File 'app/models/pageflow/published_entry.rb', line 39

def stylesheet_model
  custom_revision? ? revision : entry
end

#thumbnail_fileObject



51
52
53
54
55
# File 'app/models/pageflow/published_entry.rb', line 51

def thumbnail_file
  share_image_file ||
    pages.first.try(:thumbnail_file) ||
    PositionedFile.null
end

#thumbnail_url(*args) ⇒ Object



47
48
49
# File 'app/models/pageflow/published_entry.rb', line 47

def thumbnail_url(*args)
  thumbnail_file.thumbnail_url(*args)
end

#titleObject



35
36
37
# File 'app/models/pageflow/published_entry.rb', line 35

def title
  revision.title.presence || entry.title
end