Module: IiifPrint::SolrDocumentDecorator

Defined in:
app/models/concerns/iiif_print/solr_document_decorator.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



18
19
20
21
# File 'app/models/concerns/iiif_print/solr_document_decorator.rb', line 18

def method_missing(method_name, *args, &block)
  super unless iiif_print_solr_field_names.include? method_name.to_s
  self[IiifPrint.solr_name(method_name.to_s)]
end

Instance Method Details

#any_highlighting?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/concerns/iiif_print/solr_document_decorator.rb', line 32

def any_highlighting?
  response&.[]('highlighting')&.[](id)&.present?
end

#any_highlighting_in_all_text_fields?Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
# File 'app/models/concerns/iiif_print/solr_document_decorator.rb', line 36

def any_highlighting_in_all_text_fields?
  [CatalogController.blacklight_config.iiif_search[:full_text_field]].any? do |field|
    highlights = response&.dig('highlighting', id, field)
    highlights&.any? { |text| text.include?("<span class='highlight'>") }
  end
end

#digest_hexObject



5
6
7
8
9
10
# File 'app/models/concerns/iiif_print/solr_document_decorator.rb', line 5

def digest_hex
  raw = digest
  return nil if raw.blank?
  # Wings/Fedora stores "urn:sha1:HEX" or "urn:md5:HEX"; Valkyrie stores a plain hex string.
  raw[/\Aurn:[^:]+:([\w]+)\z/, 1] || raw
end

#digest_sha1Object



12
13
14
15
16
# File 'app/models/concerns/iiif_print/solr_document_decorator.rb', line 12

def digest_sha1
  Deprecation.warn(self, "#digest_sha1 is deprecated; use #digest_hex instead. " \
                         "#digest_sha1 will be removed in the next major version.")
  digest_hex
end

#file_set_idsObject

consists of member_ids_ssim + its descendents’ member_ids (recursively)



28
29
30
# File 'app/models/concerns/iiif_print/solr_document_decorator.rb', line 28

def file_set_ids
  self['descendent_member_ids_ssim'] || self['member_ids_ssim']
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/concerns/iiif_print/solr_document_decorator.rb', line 23

def respond_to_missing?(method_name, include_private = false)
  iiif_print_solr_field_names.include?(method_name.to_s) || super
end

#solr_documentObject



43
44
45
# File 'app/models/concerns/iiif_print/solr_document_decorator.rb', line 43

def solr_document
  self
end