Sha256: de9d2158d4c75e1126e0a7c6f0132b06d2d4d83643336d46a91c1b25c718f232

Contents?: true

Size: 1.97 KB

Versions: 6

Compression:

Stored size: 1.97 KB

Contents

module Pageflow
  # A simplified view of an entry at a given revision. Hides the
  # revision concept and makes revision attributes available along
  # with entry attributes.
  class EntryAtRevision
    include ActiveModel::Conversion

    attr_reader :entry, :revision

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

    delegate(:id, :slug,
             :entry_type,
             :account, :site,
             :permalink,
             :feature_state, :enabled_feature_names,
             :edit_lock,
             :password_digest,
             :to_model, :to_key, :to_param, :persisted?, :to_json,
             :first_published_at, :published_until, :published?,
             :last_published_with_noindex?,
             :type_name,
             to: :entry)

    delegate(:title, :summary, :credits,
             :widgets,
             :storylines, :main_storyline_chapters, :chapters, :pages,
             :share_url, :share_image_id, :share_image_x, :share_image_y,
             :share_providers, :active_share_providers,
             :find_files, :find_file, :find_file_by_perma_id,
             :image_files, :video_files, :audio_files,
             :locale,
             :author, :publisher, :keywords,
             :published_at,
             :noindex?,
             :configuration,
             to: :revision)

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

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

    def home_button
      HomeButton.new(revision, site)
    end

    def overview_button
      OverviewButton.new(revision)
    end

    def manual_start
      revision.configuration['manual_start']
    end

    def emphasize_chapter_beginning
      revision.configuration['emphasize_chapter_beginning']
    end

    def emphasize_new_pages
      revision.configuration['emphasize_new_pages']
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pageflow-17.0.4 app/models/pageflow/entry_at_revision.rb
pageflow-17.0.3 app/models/pageflow/entry_at_revision.rb
pageflow-17.0.2 app/models/pageflow/entry_at_revision.rb
pageflow-17.0.1 app/models/pageflow/entry_at_revision.rb
pageflow-17.0.0 app/models/pageflow/entry_at_revision.rb
pageflow-16.2.0 app/models/pageflow/entry_at_revision.rb