module Blacklight::Solr::Document::Marc

Public Class Methods

extended(document) click to toggle source
# File lib/blacklight/solr/document/marc.rb, line 26
def self.extended(document)
  # Register our exportable formats, we inherit these from MarcExport
  Blacklight::Solr::Document::MarcExport.register_export_formats( document )
end

Public Instance Methods

to_marc() click to toggle source

ruby-marc object

# File lib/blacklight/solr/document/marc.rb, line 32
def to_marc
  @_ruby_marc_obj ||= load_marc
end

Protected Instance Methods

_marc_format_type() click to toggle source
# File lib/blacklight/solr/document/marc.rb, line 66
def _marc_format_type
      #TODO: Raise if not present
  self.class.extension_parameters[:marc_format_type]    
end
_marc_helper() click to toggle source
# File lib/blacklight/solr/document/marc.rb, line 57
def _marc_helper
  @_marc_helper ||= (
    Blacklight::Marc::Document.new fetch(_marc_source_field), _marc_format_type )
end
_marc_source_field() click to toggle source
# File lib/blacklight/solr/document/marc.rb, line 62
def _marc_source_field    
  self.class.extension_parameters[:marc_source_field]
end
load_marc() click to toggle source
# File lib/blacklight/solr/document/marc.rb, line 42
def load_marc
  case _marc_format_type.to_s
  when 'marcxml'
    records = MARC::XMLReader.new(StringIO.new( fetch(_marc_source_field) )).to_a
    return records[0]
  when 'marc21'
    return MARC::Record.new_from_marc( fetch(_marc_source_field) )          
  else

    raise UnsupportedMarcFormatType.new("Only marcxml and marc21 are supported, this documents format is #{_marc_format_type} and the current extension parameters are #{self.class.extension_parameters.inspect}")
  end      
end
marc_source() click to toggle source
# File lib/blacklight/solr/document/marc.rb, line 38
def marc_source
  @_marc_source ||= fetch(_marc_source_field)
end