Class: IIIFManifest::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/iiif_manifest/configuration.rb

Overview

Handles configuration for the IIIFManifest gem

See Also:

Constant Summary collapse

DEFAULT_MANIFEST_PROPERTY_TO_RECORD_METHOD_NAME_MAP =
{
  summary: :description, # for V3 manifests
  description: :description, # for V2 manifests
  label: :to_s,
  rights: :rights_statement,
  homepage: :homepage
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#manifest_property_to_record_method_name_mapHash<Symbol, Symbol>

Used to map a record’s public method to a manifest property.



27
28
29
30
# File 'lib/iiif_manifest/configuration.rb', line 27

def manifest_property_to_record_method_name_map
  # the constant is frozen but we need to be able to configure something unfrozen
  @manifest_property_to_record_method_name_map ||= DEFAULT_MANIFEST_PROPERTY_TO_RECORD_METHOD_NAME_MAP.dup
end

#manifest_thumbnailBoolean

Used to configure whether or not to show the manifest thumbnail property.

Returns:

  • (Boolean)


45
46
47
48
# File 'lib/iiif_manifest/configuration.rb', line 45

def manifest_thumbnail
  return @manifest_thumbnail unless @manifest_thumbnail.nil?
  @manifest_thumbnail = true
end

#max_edge_for_thumbnailInteger

Used to set max edge length for thumbnail generation.

Returns:

  • (Integer)


37
38
39
40
# File 'lib/iiif_manifest/configuration.rb', line 37

def max_edge_for_thumbnail
  return @max_edge_for_thumbnail unless @max_edge_for_thumbnail.nil?
  @max_edge_for_thumbnail = 200
end

Instance Method Details

#manifest_value_for(record, property:) ⇒ NilClass, #to_s

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • record (Object)

    has the value for the :property we want to set

  • property (Symbol)

    IIIF manifest property

Returns:

  • (NilClass)

    the record does not have a value for the given property

  • (#to_s)

    the record has a value that is “present”



56
57
58
59
60
# File 'lib/iiif_manifest/configuration.rb', line 56

def manifest_value_for(record, property:)
  method_name = map_property_to_method_name(property: property)
  return nil unless record.respond_to?(method_name)
  record.public_send(method_name)
end