Module: Blacklight::Document::Extensions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/blacklight/document/extensions.rb
Overview
Document Extensions
An Blacklight::Document extension is simply a ruby module which is mixed in to individual Document instances. The intended use case is for documents containing some particular format of source material, such as Marc. An extension can be registered with your document class, along with a block containing custom logic for which documents to apply the extension to.
SolrDocument.use_extension(MyExtension) { |document| my_logic_on_document(document) }
MyExtension will be mixed-in (using ruby ‘extend’) only to those documents where the block results in true.
Extension Parameters
Every class that includes Blacklight::Solr::Document::Extensions gets a #extension_parameters method for saving arbitrary parameters on class-wide level that can be retrieved by extensions. These are arbitrary, just conventions with a given extension. For instance: SolrDocument.extension_parameters = “solr_stored_field_name”
Instance Method Summary collapse
-
#apply_extensions ⇒ Object
Needs to be called in initializer of class including this module, to apply all registered extensions on a per-document basis.
Instance Method Details
#apply_extensions ⇒ Object
Needs to be called in initializer of class including this module, to apply all registered extensions on a per-document basis
27 28 29 30 31 |
# File 'app/models/concerns/blacklight/document/extensions.rb', line 27 def apply_extensions self.class.registered_extensions.each do |registration| extend(registration[:module_obj]) if registration[:condition_proc].nil? || registration[:condition_proc].call(self) end end |