Class: Schematron
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Schematron
- Defined in:
- app/models/schematron.rb
Overview
A particular version of a Schematron document used to check FindingAids for Issues
Generated by XML processing of a schematron file
Defined Under Namespace
Classes: SchematronFileValidator
Instance Attribute Summary (collapse)
Has many (collapse)
Class Method Summary (collapse)
-
+ (Object) create_from_file(sf)
Alternate convenience constructor.
-
+ (Schematron) current
Gets most recently created Schematron.
Instance Method Summary (collapse)
-
- (SchematronFile) file
The SchematronFile associated with this record.
Instance Attribute Details
- (DateTime) created_at
113 |
# File 'db/schema.rb', line 113 t.datetime "created_at" |
- (String) digest
Validations:
- Length ({is: 64})
- Format ({with: /[a-zA-Z0-9]+/})
- Presence
- Uniqueness
- Schematron_file
19 20 21 22 23 24 |
# File 'app/models/schematron.rb', line 19 validates :digest, length: {is: 64}, format: {with: /[a-zA-Z0-9]+/}, presence: true, uniqueness: true, schematron_file: true |
- (DateTime) updated_at
114 |
# File 'db/schema.rb', line 114 t.datetime "updated_at" |
Class Method Details
+ (Object) create_from_file(sf)
Alternate convenience constructor
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/schematron.rb', line 29 def self.create_from_file(sf) if sf.kind_of? IO sf = SchematronFile.new(sf.read) end me = Schematron.find_by(digest: sf.digest) || Schematron.new(digest: sf.digest, issues_attributes: sf.issue_attrs) if me.persisted? me.touch else me.save end me end |
+ (Schematron) current
Gets most recently created Schematron
48 49 50 |
# File 'app/models/schematron.rb', line 48 def self.current order(updated_at: :desc).first end |
Instance Method Details
- (SchematronFile) file
Returns the SchematronFile associated with this record
53 54 55 |
# File 'app/models/schematron.rb', line 53 def file SchematronFile[digest] end |
- (ActiveRecord::Relation<Issue>) issues
13 |
# File 'app/models/schematron.rb', line 13 has_many :issues, dependent: :destroy, inverse_of: :schematron |