app/presenters/outline_presenter.rb in woople-theme-0.0.6 vs app/presenters/outline_presenter.rb in woople-theme-0.1.0

- old
+ new

@@ -1,31 +1,38 @@ +require 'action_view' require 'delegate' class OutlinePresenter < SimpleDelegator - def assessment - css_class = "assessment" - css_class << " disabled" if assessment_disabled? + include ActionView::Helpers::TagHelper - yield(css_class) if has_assessment? - end + attr_accessor :view_context - def render_downloads(view_context) - wrapped_downloads = ThemePresentation.wrap_collection(downloads, OutlineDownloadPresenter) - view_context.render partial: 'woople-theme/outline_download', collection: wrapped_downloads + def name + content_tag(:h2, outline.name) end - def render_videos(view_context) + def videos(videos = outline.videos) wrapped_videos = ThemePresentation.wrap_collection(videos, OutlineVideoPresenter) - view_context.render partial: 'woople-theme/outline_video', collection: wrapped_videos + view_context.render partial: 'woople-theme/outline_videos', locals: { videos: wrapped_videos } end - def downloads - outline.downloads + 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 videos - outline.videos + 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