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