Class: Pageflow::EntryAtRevision

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Conversion
Defined in:
app/models/pageflow/entry_at_revision.rb

Overview

A simplified view of an entry at a given revision. Hides the revision concept and makes revision attributes available along with entry attributes.

Direct Known Subclasses

DraftEntry, PublishedEntry

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry, revision, theme: nil) ⇒ EntryAtRevision

Returns a new instance of EntryAtRevision.



10
11
12
13
14
# File 'app/models/pageflow/entry_at_revision.rb', line 10

def initialize(entry, revision, theme: nil)
  @entry = entry
  @revision = revision
  @theme = theme
end

Instance Attribute Details

#entryObject (readonly)

Returns the value of attribute entry.



8
9
10
# File 'app/models/pageflow/entry_at_revision.rb', line 8

def entry
  @entry
end

#revisionObject (readonly)

Returns the value of attribute revision.



8
9
10
# File 'app/models/pageflow/entry_at_revision.rb', line 8

def revision
  @revision
end

Class Method Details

.wrap_all_drafts(entries) ⇒ Object



79
80
81
# File 'app/models/pageflow/entry_at_revision.rb', line 79

def self.wrap_all_drafts(entries)
  entries.includes(:draft).map { |entry| new(entry, entry.draft) }
end

Instance Method Details

#emphasize_chapter_beginningObject



71
72
73
# File 'app/models/pageflow/entry_at_revision.rb', line 71

def emphasize_chapter_beginning
  revision.configuration['emphasize_chapter_beginning']
end

#emphasize_new_pagesObject



75
76
77
# File 'app/models/pageflow/entry_at_revision.rb', line 75

def emphasize_new_pages
  revision.configuration['emphasize_new_pages']
end

#home_buttonObject



59
60
61
# File 'app/models/pageflow/entry_at_revision.rb', line 59

def home_button
  HomeButton.new(revision, site)
end


55
56
57
# File 'app/models/pageflow/entry_at_revision.rb', line 55

def legal_info
  @legal_info ||= site.legal_info(locale:)
end

#manual_startObject



67
68
69
# File 'app/models/pageflow/entry_at_revision.rb', line 67

def manual_start
  revision.configuration['manual_start']
end

#overview_buttonObject



63
64
65
# File 'app/models/pageflow/entry_at_revision.rb', line 63

def overview_button
  OverviewButton.new(revision)
end

#resolve_widgets(options = {}) ⇒ Object



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

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

#themeObject



51
52
53
# File 'app/models/pageflow/entry_at_revision.rb', line 51

def theme
  @theme ||= CustomizedTheme.find(entry: self, theme: revision.theme)
end