Sha256: 33e3d5f5183b4ede788a08c23e46a97d11680b26e8b753c4d7e9127b8186fff4

Contents?: true

Size: 1022 Bytes

Versions: 12

Compression:

Stored size: 1022 Bytes

Contents

# frozen_string_literal: true

require 'arclight/viewers/oembed'

module Arclight
  ##
  # Arclight::Viewer provides the ability to render a configured viewer
  # The viewer class is configured through the Arclight::Engine configuration
  # which allows an application to implement their own viewer class.
  # This class will receive a SolrDocument and must implement to_partial_path.
  # See Arclight::Viewers::OEmbed for an example implementation of a viewer.
  class Viewer
    def self.render(document)
      new(document).render
    end

    def initialize(document)
      @document = document
    end

    def render
      renderer.render(
        viewer_instance.to_partial_path,
        layout: false,
        locals: { viewer: viewer_instance }
      )
    end

    private

    attr_reader :document

    def viewer_instance
      viewer_class.new(document)
    end

    def viewer_class
      Arclight::Engine.config.viewer_class
    end

    def renderer
      ApplicationController.renderer
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
arclight-0.5.0 lib/arclight/viewer.rb
arclight-0.4.0 lib/arclight/viewer.rb
arclight-0.3.3 lib/arclight/viewer.rb
arclight-0.3.2 lib/arclight/viewer.rb
arclight-0.3.1 lib/arclight/viewer.rb
arclight-0.3.0 lib/arclight/viewer.rb
arclight-0.2.0 lib/arclight/viewer.rb
arclight-0.1.4 lib/arclight/viewer.rb
arclight-0.1.3 lib/arclight/viewer.rb
arclight-0.1.2 lib/arclight/viewer.rb
arclight-0.1.1 lib/arclight/viewer.rb
arclight-0.1.0 lib/arclight/viewer.rb