Class: MARCSerializer
  
  
  
  
    - Inherits:
 
    - 
      ASpaceExport::Serializer
      
        
        show all
      
      
 
    
  
  
    
  
    
  
  
  
    - Defined in:
 
    - backend/app/exporters/serializers/marc21.rb
 
  
  
    
      Class Method Summary
      (collapse)
    
    
  
    
      Instance Method Summary
      (collapse)
    
    
  
  
  
  
  
  
  
  
  
  
  inherited, serializer_for, serializer_for?, with_namespace
  
    Class Method Details
    
      
  
  
    + (Object) add_decorator(decorator) 
  
  
  
  
    Allow plugins to wrap the MARC record with their own behavior.  Gives them
the chance to change the leader, 008, add extra data fields, etc.
   
 
  
  
    
      
15
16
17
18 
     | 
    
      # File 'backend/app/exporters/serializers/marc21.rb', line 15
def self.add_decorator(decorator)
  @decorators ||= []
  @decorators << decorator
end
 
     | 
  
 
    
      
  
  
    + (Object) decorate_record(record) 
  
  
  
  
    
      
20
21
22
23
24 
     | 
    
      # File 'backend/app/exporters/serializers/marc21.rb', line 20
def self.decorate_record(record)
  Array(@decorators).reduce(record) {|result, decorator|
    decorator.new(result)
  }
end
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    - (Object) build(marc, opts = {}) 
  
  
  
  
    
      
4
5
6
7
8
9
10
11 
     | 
    
      # File 'backend/app/exporters/serializers/marc21.rb', line 4
def build(marc, opts = {})
  builder = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml|
    _root(marc, xml)
  end
  builder
end
     | 
  
 
    
      
  
  
    - (Object) serialize(marc, opts = {}) 
  
  
  
  
    
      
27
28
29
30
31
32 
     | 
    
      # File 'backend/app/exporters/serializers/marc21.rb', line 27
def serialize(marc, opts = {})
  builder = build(MARCSerializer.decorate_record(marc), opts)
  builder.to_xml
end
     |