Class: Bulkrax::ParserExportRecordSet::Base Abstract
- Inherits:
- 
      Object
      
        - Object
- Bulkrax::ParserExportRecordSet::Base
 
- Defined in:
- app/parsers/bulkrax/parser_export_record_set.rb
Overview
Direct Known Subclasses
Instance Method Summary collapse
- #count ⇒ Integer
- 
  
    
      #each {|id, entry_class| ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Yield first the works, then collections, then file sets. 
- 
  
    
      #initialize(parser:)  ⇒ Base 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Base. 
Constructor Details
#initialize(parser:) ⇒ Base
Returns a new instance of Base.
| 54 55 56 | # File 'app/parsers/bulkrax/parser_export_record_set.rb', line 54 def initialize(parser:) @parser = parser end | 
Instance Method Details
#count ⇒ Integer
| 65 66 67 68 69 70 | # File 'app/parsers/bulkrax/parser_export_record_set.rb', line 65 def count sum = works.count + collections.count + file_sets.count return sum if limit.zero? return limit if sum > limit return sum end | 
#each {|id, entry_class| ... } ⇒ Object
    Note:
    
  
The order of what we yield has been previously determined.
Yield first the works, then collections, then file sets. Once we’ve yielded as many times as the parser’s limit, we break the iteration and return.
| 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | # File 'app/parsers/bulkrax/parser_export_record_set.rb', line 81 def each counter = 0 works.each do |work| break if limit_reached?(limit, counter) yield(work.fetch('id'), work_entry_class) counter += 1 end return if limit_reached?(limit, counter) collections.each do |collection| break if limit_reached?(limit, counter) yield(collection.fetch('id'), collection_entry_class) counter += 1 end return if limit_reached?(limit, counter) file_sets.each do |file_set| break if limit_reached?(limit, counter) yield(file_set.fetch('id'), file_set_entry_class) counter += 1 end end |