Module: Blacklight::Solr::Document::Extensions::ClassMethods

Defined in:
lib/blacklight/solr/document/extensions.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) registered_extensions

want to zero out all previously registered extensions you can call: SolrDocument.registered_extensions = nil



36
37
38
# File 'lib/blacklight/solr/document/extensions.rb', line 36

def registered_extensions
  @registered_extensions ||= []
end

Instance Method Details

- (Object) extension_parameters



40
41
42
# File 'lib/blacklight/solr/document/extensions.rb', line 40

def extension_parameters
  @extension_parameters ||= {}
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



52
53
54
# File 'lib/blacklight/solr/document/extensions.rb', line 52

def use_extension( module_obj, &condition )
  registered_extensions << {:module_obj => module_obj, :condition_proc => condition}    
end