Sha256: 726a4e407fc8d7aeebd49cabb96d0a6e3783c37d921bfc08f8df1c72c901cef1

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

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.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, 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

3 entries across 3 versions & 1 rubygems

Version Path
bit_core-2.0.0.beta1 app/models/bit_core/content_providers/slideshow_provider.rb
bit_core-1.4.6 app/models/bit_core/content_providers/slideshow_provider.rb
bit_core-1.4.5 app/models/bit_core/content_providers/slideshow_provider.rb