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.
30 31 32 |
# File 'app/parsers/bulkrax/parser_export_record_set.rb', line 30 def initialize(parser:) @parser = parser end |
Instance Method Details
#count ⇒ Integer
40 41 42 43 44 45 |
# File 'app/parsers/bulkrax/parser_export_record_set.rb', line 40 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.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/parsers/bulkrax/parser_export_record_set.rb', line 55 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 |