Class: FindingAidVersion
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- FindingAidVersion
- Defined in:
- app/models/finding_aid_version.rb
Overview
A specific version of an archival finding aid.
This is a concrete representation, specified by file content
Defined Under Namespace
Classes: FindingAidFileValidator
Instance Attribute Summary (collapse)
- - (DateTime) created_at
- - (String) digest
- - (String) unitid
- - (String) unittitle
- - (DateTime) updated_at
Belongs to (collapse)
Delegated Instance Attributes (collapse)
-
- (Object) eadid
Alias for Finding_aid#eadid.
Has and belongs to many (collapse)
Has many (collapse)
- - (ActiveRecord::Relation<ConcreteIssue>) concrete_issues
- - (ActiveRecord::Relation<ProcessingEvent>) processing_events
Class Method Summary (collapse)
-
+ (Object) create_from_file(fa)
Alternate convenience constructor.
Instance Method Summary (collapse)
-
- (FindingAidFile) file
The FindingAidFile associated with this record.
-
- (Object) to_param
Param for URL is digest.
-
- (Nokogiri::XML::Document) xml
Parsed XML representation of FindingAidFile.
Instance Attribute Details
- (DateTime) created_at
38 |
# File 'db/schema.rb', line 38 t.datetime "created_at" |
- (String) digest
Validations:
- Length ({is: 64})
- Format ({with: /[a-zA-Z0-9]+/})
- Presence
- Uniqueness
- Finding_aid_file
23 24 25 26 27 28 |
# File 'app/models/finding_aid_version.rb', line 23 validates :digest, length: {is: 64}, format: {with: /[a-zA-Z0-9]+/}, presence: true, uniqueness: true, finding_aid_file: true |
- (String) unitid
41 |
# File 'db/schema.rb', line 41 t.string "unitid", limit: 255 |
- (String) unittitle
40 |
# File 'db/schema.rb', line 40 t.string "unittitle", limit: 255 |
- (DateTime) updated_at
39 |
# File 'db/schema.rb', line 39 t.datetime "updated_at" |
Class Method Details
+ (Object) create_from_file(fa)
Alternate convenience constructor
38 39 40 41 42 43 44 45 |
# File 'app/models/finding_aid_version.rb', line 38 def self.create_from_file(fa) if fa.kind_of? IO fa = FindingAidFile.new(fa.read) end attr = fa.fav_attr FindingAidVersion.find_by(digest: attr[:digest]) || FindingAidVersion.create(attr) end |
Instance Method Details
- (ActiveRecord::Relation<ConcreteIssue>) concrete_issues
18 |
# File 'app/models/finding_aid_version.rb', line 18 has_many :concrete_issues, dependent: :destroy |
- (Object) eadid
Alias for Finding_aid#eadid
16 |
# File 'app/models/finding_aid_version.rb', line 16 delegate :eadid, to: :finding_aid |
- (FindingAidFile) file
Returns the FindingAidFile associated with this record
49 50 51 |
# File 'app/models/finding_aid_version.rb', line 49 def file FindingAidFile[digest] end |
- (FindingAid) finding_aid
15 |
# File 'app/models/finding_aid_version.rb', line 15 belongs_to :finding_aid |
- (ActiveRecord::Relation<ProcessingEvent>) processing_events
19 |
# File 'app/models/finding_aid_version.rb', line 19 has_many :processing_events |
- (ActiveRecord::Relation<Run>) runs
17 |
# File 'app/models/finding_aid_version.rb', line 17 has_and_belongs_to_many :runs |
- (Object) to_param
Param for URL is digest
31 32 33 |
# File 'app/models/finding_aid_version.rb', line 31 def to_param digest end |
- (Nokogiri::XML::Document) xml
Returns parsed XML representation of FindingAidFile
54 55 56 |
# File 'app/models/finding_aid_version.rb', line 54 def xml Nokogiri.XML(file, nil, 'UTF-8') {|config| config.nonet;config.noent} end |