Skip to content

Instantly share code, notes, and snippets.

@mwmitchell
Created April 6, 2009 17:38
Show Gist options
  • Save mwmitchell/90853 to your computer and use it in GitHub Desktop.
Save mwmitchell/90853 to your computer and use it in GitHub Desktop.
#
# A module to help marc related solr documents
#
# Example:
# docs.each{|d| d.extend(SolrMARCDocument) if d[:marc_display] }
#
module SolrMARCDocument
def marc
@marc ||= (
reader = MARC::XMLReader.new(StringIO.new(self.marc_display)).to_a
reader[0]
)
end
def marc_xml
self.marc.to_xml.to_s
end
def to_xml
self.marc_xml
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment