Sha256: 7ce99707b9348ccea074b4c755ac382d38f82507c641967ef59a23513026f142

Contents?: true

Size: 1.19 KB

Versions: 29

Compression:

Stored size: 1.19 KB

Contents

require 'action_view'
require 'delegate'

class OutlinePresenter < SimpleDelegator
  include ActionView::Helpers::TagHelper

  attr_accessor :view_context

  def name
    content_tag(:h2, outline.name)
  end

  def videos(videos = outline.videos)
    wrapped_videos = ThemePresentation.wrap_collection(videos, OutlineVideoPresenter)
    view_context.render partial: 'woople-theme/outline_videos', locals: { videos: wrapped_videos }
  end

  def downloads(downloads = outline.downloads)
    wrapped_downloads = ThemePresentation.wrap_collection(downloads, OutlineDownloadPresenter)
    view_context.render partial: 'woople-theme/outline_downloads', locals: { downloads: wrapped_downloads }
  end

  def assessment
    view_context.render partial: 'woople-theme/outline_assessment', locals: { outline: self }
  end

  def render_assessment
    css_class = "assessment"
    css_class << " disabled" if assessment_disabled?

    yield(css_class) if has_assessment?
  end

  private

  def assessment_disabled?
    outline.respond_to?(:assessment_enabled) && !outline.assessment_enabled
  end

  def has_assessment?
    outline.respond_to?(:assessment) && outline.assessment
  end

  def outline
    __getobj__
  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
woople-theme-0.2.27 app/presenters/outline_presenter.rb
woople-theme-0.2.26 app/presenters/outline_presenter.rb
woople-theme-0.2.25 app/presenters/outline_presenter.rb
woople-theme-0.2.24 app/presenters/outline_presenter.rb
woople-theme-0.2.23 app/presenters/outline_presenter.rb
woople-theme-0.2.22 app/presenters/outline_presenter.rb
woople-theme-0.2.21 app/presenters/outline_presenter.rb
woople-theme-0.2.20 app/presenters/outline_presenter.rb
woople-theme-0.2.19 app/presenters/outline_presenter.rb
woople-theme-0.2.18 app/presenters/outline_presenter.rb
woople-theme-0.2.17 app/presenters/outline_presenter.rb
woople-theme-0.2.16 app/presenters/outline_presenter.rb
woople-theme-0.2.15 app/presenters/outline_presenter.rb
woople-theme-0.2.14 app/presenters/outline_presenter.rb
woople-theme-0.2.13 app/presenters/outline_presenter.rb
woople-theme-0.2.12 app/presenters/outline_presenter.rb
woople-theme-0.2.11 app/presenters/outline_presenter.rb
woople-theme-0.2.10 app/presenters/outline_presenter.rb
woople-theme-0.2.9 app/presenters/outline_presenter.rb
woople-theme-0.2.8 app/presenters/outline_presenter.rb