Class: RecordCrossrefProcessor
- Inherits:
-
Object
- Object
- RecordCrossrefProcessor
- Defined in:
- lib/record_crossref_processor.rb
Overview
Based on an array of records, attach crossref information for each
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(records, db) ⇒ RecordCrossrefProcessor
constructor
A new instance of RecordCrossrefProcessor.
- #process_records ⇒ Object
Constructor Details
#initialize(records, db) ⇒ RecordCrossrefProcessor
Returns a new instance of RecordCrossrefProcessor.
32 33 34 35 36 37 |
# File 'lib/record_crossref_processor.rb', line 32 def initialize(records,db) @records=records @db=db @result=Result.new() process_records end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
31 32 33 |
# File 'lib/record_crossref_processor.rb', line 31 def result @result end |
Instance Method Details
#process_records ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/record_crossref_processor.rb', line 38 def process_records correct=true @records.each do |record| @db.transaction() do begin # A very fast comprobation, comparing canonical document and record if record.doi.to_s=="" and record.canonical_document.doi!="" record.update(:doi=>record.canonical_document.doi) else @result.add_result(record.add_doi_automatic) end if record.doi result.add_result(record.references_automatic_crossref) end rescue BadCrossrefResponseError=>e result.error(I18n::t("error.problem_record_stop_sync", record_id: record[:id], e_message: e.)) raise Sequel::Rollback end @db.after_rollback { correct=false } end break unless correct end end |