Module: Blacklight::Solr::Document::ExtendableClassMethods
- Defined in:
- vendor/plugins/blacklight/lib/blacklight/solr/document.rb
Overview
Certain class-level modules needed for the document-specific extendability architecture
Instance Attribute Summary (collapse)
-
- (Object) registered_extensions
Returns array of hashes of registered extensions.
Instance Method Summary (collapse)
-
- (Object) field_semantics
Class-level method for accessing/setting semantic mappings for solr stored fields.
-
- (Object) use_extension(module_obj, &condition)
Register an extension module with the class.
Instance Attribute Details
- (Object) registered_extensions
Returns array of hashes of registered extensions. Each hash has a :module_obj key and a :condition_proc key. Usually this method is only used internally in #apply_extensions, but if you want to zero out all previously registered extensions you can call: SolrDocument.registered_extensions = nil
211 212 213 |
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document.rb', line 211 def registered_extensions @registered_extensions ||= [] end |
Instance Method Details
- (Object) field_semantics
Class-level method for accessing/setting semantic mappings for solr stored fields. Can be set by local app, key is a symbol for a semantic, value is a solr stored field.
Stored field can be single or multi-value. In some cases clients may only use the first value from a multi-value field.
Currently documented semantic tokens, not all may be used by core BL, but some may be used by plugins present or future. :title, :author, :year, :language => User-presentable strings.
238 239 240 |
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document.rb', line 238 def field_semantics @field_semantics ||= {} end |
- (Object) use_extension(module_obj, &condition)
Register an extension module with the class. A block taking one parameter can be supplied; the block will be passed an instance of a Document, and the extension will be applied only if the block evaluates as true. If no condition is given, the extension will be applied to every instance of the class.
SolrDocument.use_extension( SomeExtensionModule ) { | document | should_apply_some_extension?(document) } SolrDocument.use_extension( SomeExtensionModule) # will be applied to all docs
223 224 225 |
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document.rb', line 223 def use_extension( module_obj, &condition ) registered_extensions << {:module_obj => module_obj, :condition_proc => condition} end |