Sha256: 7338dd4d94244e28eec286cc6b50c659107147f93d3203c466844c92885c3040

Contents?: true

Size: 984 Bytes

Versions: 3

Compression:

Stored size: 984 Bytes

Contents

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

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

      def slide(position)
        slideshow.slides.where(position: position).first ||
          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)
        if source_content
          source_content.update(title: title)
        else
          slideshow = BitCore::Slideshow.create(title: title)
          update(source_content: slideshow)
        end

        source_content
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bit_core-1.2.2 app/models/bit_core/content_providers/slideshow_provider.rb
bit_core-1.2.1 app/models/bit_core/content_providers/slideshow_provider.rb
bit_core-1.2.0 app/models/bit_core/content_providers/slideshow_provider.rb