Sha256: 2b091f4ab35ceb50ecb222bf4085eb9df71005294cf0d972c5adfb5167087c84

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true
module BitCore
  module ContentProviders
    # Defines presentation logic for a Slideshow.
    class SlideshowProvider < BitCore::ContentProvider
      def slideshow
        source_content || Slideshow.new
      end

      def render_current(options)
        options.view_context.render(
          template: "slides/show",
          locals: {
            slide: slide(options.position)
          }
        )
      end

      def slide(position)
        slideshow.slides.find_by(position: position) ||
          BitCore::Slide.new(body: "no slides")
      end

      def exists?(position)
        slideshow.slides.exists?(position: position)
      end

      def show_nav_link?
        true
      end

      def add_or_update_slideshow(title, arm_id = nil)
        if source_content
          source_content.update(title: title)
        else
          slideshow = BitCore::Slideshow.create(arm_id: arm_id, title: title)
          update(source_content: slideshow)
        end

        source_content
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bit_core-1.4.7 app/models/bit_core/content_providers/slideshow_provider.rb
bit_core-2.0.0.beta2 app/models/bit_core/content_providers/slideshow_provider.rb