Class: Hyrax::ManifestBuilderService

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/manifest_builder_service.rb

Overview

A class responsible for converting a Hyrax::Work like thing into a IIIF manifest.

See Also:

  • !{!{.as_json}

Direct Known Subclasses

CachingIiifManifestBuilder

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(iiif_manifest_factory: ::IIIFManifest::ManifestFactory) ⇒ ManifestBuilderService

Returns a new instance of ManifestBuilderService.

Parameters:

  • iiif_manifest_factory (Class) (defaults to: ::IIIFManifest::ManifestFactory)

    a class that initializes with presenter object and returns an object that responds to ‘#to_h`



39
40
41
# File 'app/services/hyrax/manifest_builder_service.rb', line 39

def initialize(iiif_manifest_factory: ::IIIFManifest::ManifestFactory)
  @manifest_factory = iiif_manifest_factory
end

Instance Attribute Details

#manifest_factoryObject (readonly)

Returns the value of attribute manifest_factory.



32
33
34
# File 'app/services/hyrax/manifest_builder_service.rb', line 32

def manifest_factory
  @manifest_factory
end

Class Method Details

.manifest_for(presenter:, iiif_manifest_factory: ::IIIFManifest::ManifestFactory) ⇒ Hash

Note:

While the :presenter may be a Hyrax::WorkShowPresenter it is likely defined by Hyrax::WorksControllerBehavior.show_presenter

Returns a Ruby hash representation of a IIIF manifest document.

Parameters:

  • presenter (Hyrax::WorkShowPresenter)

    the work presenter from which we’ll build a manifest.

  • iiif_manifest_factory (Class) (defaults to: ::IIIFManifest::ManifestFactory)

    a class that initializes with presenter object and returns an object that responds to ‘#to_h`

Returns:

  • (Hash)

    a Ruby hash representation of a IIIF manifest document

See Also:



24
25
26
27
# File 'app/services/hyrax/manifest_builder_service.rb', line 24

def self.manifest_for(presenter:, iiif_manifest_factory: ::IIIFManifest::ManifestFactory)
  new(iiif_manifest_factory: iiif_manifest_factory)
    .manifest_for(presenter: presenter)
end

Instance Method Details

#manifest_for(presenter:) ⇒ Hash

Returns a Ruby hash representation of a IIIF manifest document.

Parameters:

Returns:

  • (Hash)

    a Ruby hash representation of a IIIF manifest document



49
50
51
# File 'app/services/hyrax/manifest_builder_service.rb', line 49

def manifest_for(presenter:)
  sanitized_manifest(presenter: presenter)
end