Class: DocumentLicensedAccess
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- DocumentLicensedAccess
- Defined in:
- app/models/document_licensed_access.rb
Overview
DocumentLicensedAccess
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.destroy_all(file) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/models/document_licensed_access.rb', line 25 def self.destroy_all(file) logger.debug("CSV Destroy") ::CSV.foreach(file.path, headers: true) do |row| logger.debug("CSV Row: #{row.to_hash}") DocumentLicensedAccess.destroy_by(id: row[0], friendlier_id: row[1]) end true end |
.import(file) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/models/document_licensed_access.rb', line 15 def self.import(file) logger.debug("CSV Import") ::CSV.foreach(file.path, headers: true) do |row| logger.debug("CSV Row: #{row.to_hash}") document_licensed_access = DocumentLicensedAccess.find_or_initialize_by(friendlier_id: row[0], institution_code: row[1]) document_licensed_access.update!(row.to_hash) end true end |
Instance Method Details
#reindex_document ⇒ Object
38 39 40 |
# File 'app/models/document_licensed_access.rb', line 38 def reindex_document document.save end |
#to_csv ⇒ Object
34 35 36 |
# File 'app/models/document_licensed_access.rb', line 34 def to_csv attributes.values end |