Module: IiifPrint::Solr::Document
- Defined in:
- app/models/concerns/iiif_print/solr/document.rb
Class Method Summary collapse
-
.decorate(base) ⇒ Class<SolrDocument>
This method is responsible for configuring the SolrDocument for a Hyrax/Hyku application.
Instance Method Summary collapse
-
#file_set_ids ⇒ Object
TODO: consider configuring this field name; we use the magic field in lots of places.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
34 35 36 37 |
# File 'app/models/concerns/iiif_print/solr/document.rb', line 34 def method_missing(method_name, *args, &block) super unless iiif_print_solr_field_names.include? method_name.to_s self[::ActiveFedora.index_field_mapper.solr_name(method_name.to_s)] end |
Class Method Details
.decorate(base) ⇒ Class<SolrDocument>
Why decorate? We want to avoid including this module via generator. And the generator previously did two things: 1) include ‘IiifPrint::Solr::Document` in `SolrDocument`; 2) add the `attribute :is_child` field to the SolrDocument. We can’t rely on ‘included do` block to handle that.
These ‘iiif_print_solr_field_names` came from the newspaper_works implementation and are carried forward without much consideration, except to say “Make it configurable!”
This method is responsible for configuring the SolrDocument for a Hyrax/Hyku application. It does three things:
-
Adds instance methods to the SolrDocument (see implementation below)
-
Adds the ‘is_child` attribute to the SolrDocument
-
Adds a class attribute (e.g. ‘iiif_print_solr_field_names`) to allow further customization.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/concerns/iiif_print/solr/document.rb', line 19 def self.decorate(base) base.prepend(self) base.send(:attribute, :is_child, Hyrax::SolrDocument::Metadata::Solr::String, 'is_child_bsi') # @note These properties came from the newspaper_works gem. They are configurable. base.class_attribute :iiif_print_solr_field_names, default: %w[alternative_title genre issn lccn oclcnum held_by text_direction page_number section author photographer volume issue_number geographic_coverage extent publication_date height width edition_number edition_name frequency preceded_by succeeded_by] base end |
Instance Method Details
#file_set_ids ⇒ Object
TODO: consider configuring this field name; we use the magic field in lots of places.
44 45 46 |
# File 'app/models/concerns/iiif_print/solr/document.rb', line 44 def file_set_ids self['file_set_ids_ssim'] end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
39 40 41 |
# File 'app/models/concerns/iiif_print/solr/document.rb', line 39 def respond_to_missing?(method_name, include_private = false) iiif_print_solr_field_names.include?(method_name.to_s) || super end |