Sha256: 15d0bf880f9bc24628981c816908265371377625ce3d4faeb96805ccc623dee2

Contents?: true

Size: 433 Bytes

Versions: 10

Compression:

Stored size: 433 Bytes

Contents

module ModsDisplay::ModelExtension

  def self.included(base)
    base.extend ClassMethods
    base.class_eval do
      def mods_display_xml
        xml = self.class.mods_xml_source.call(self)
        return if xml.nil?
        mods = Stanford::Mods::Record.new
        mods.from_str(xml, false)
        mods
      end
    end
  end

  module ClassMethods
    def mods_xml_source &xml
      @mods_xml_source ||= xml
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mods_display-0.3.3 lib/mods_display/model_extension.rb
mods_display-0.3.2 lib/mods_display/model_extension.rb
mods_display-0.3.1 lib/mods_display/model_extension.rb
mods_display-0.3.0 lib/mods_display/model_extension.rb
mods_display-0.2.4 lib/mods_display/model_extension.rb
mods_display-0.2.3 lib/mods_display/model_extension.rb
mods_display-0.2.2 lib/mods_display/model_extension.rb
mods_display-0.2.1 lib/mods_display/model_extension.rb
mods_display-0.2.0 lib/mods_display/model_extension.rb
mods_display-0.1.4 lib/mods_display/model_extension.rb