Module: Blacklight::Solr::Document::Marc

Includes:
MarcExport
Defined in:
vendor/plugins/blacklight/lib/blacklight/solr/document/marc.rb

Overview

This is a document extension meant to be mixed into a Blacklight::Solr::Document class, such as SolrDocument. It provides support for restoration of MARC data (xml or binary) from a Solr stored field, and then provides various transformations/exports of that Marc via the included Blacklight::Solr::Document::MarcExport module.

This extension would normally be registered using Blacklight::Solr::Document#use_extension. eg:

SolrDocument.use_extension( Blacklight::Solr::Document::Marc ) { |document| my_logic_for_document_has_marc?( document ) }

This extension also expects a :marc_source_field and :marc_format_type to be registered with the hosting classes extension_parameters. In an initializer or other startup code: SolrDocument.extension_paramters[:marc_source_field] = “name_of_solr_stored_field” SolrDocument.extension_parameters[:marc_format_type] = :marc21 # or :marcxml

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from MarcExport

#export_as_apa_citation_txt, #export_as_endnote, #export_as_marc, #export_as_marcxml, #export_as_mla_citation_txt, #export_as_openurl_ctx_kev, #export_as_refworks_marc_txt, register_export_formats, #to_apa, #to_mla, #to_zotero

Class Method Details

+ (Object) extended(document)



24
25
26
27
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document/marc.rb', line 24

def self.extended(document)
  # Register our exportable formats, we inherit these from MarcExport    
  Blacklight::Solr::Document::MarcExport.register_export_formats( document )
end

Instance Method Details

- (Object) marc

DEPRECATED. Here for legacy purposes, but use to_marc instead. Or internally, use the protected _marc_helper method to get the (somewhat confusingly named) Blacklight::Marc::Document helper object.

This method gets attached to a SolrDocument. it uses the marc_source_field and marc_format_type class attributes to create the Blacklight::Marc::Document instance. Only returns a Blacklight::Marc::Document instance if the self.class.marc_source_field key exists.



38
39
40
41
42
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document/marc.rb', line 38

def marc
  warn "[DEPRECATION] aDocument.marc is deprecated.  Please use aDocument.respond_to?(:to_marc) / aDocument.respond_to?(:marc),  or aDocument.exports_as.keys.include?(:some_format) / aDocument.export_as(:some_format) instead."

  _marc_helper
end

- (Object) to_marc

ruby-marc object



45
46
47
# File 'vendor/plugins/blacklight/lib/blacklight/solr/document/marc.rb', line 45

def to_marc
  @_ruby_marc_obj ||= load_marc
end