Skip to content

Instantly share code, notes, and snippets.

@afred
Created March 15, 2017 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afred/dc99d18e9fe8dc1c77969b3df91ab0a9 to your computer and use it in GitHub Desktop.
Save afred/dc99d18e9fe8dc1c77969b3df91ab0a9 to your computer and use it in GitHub Desktop.
(untested) another rough code sketch for how validating rdf types for Files within FileSets might work
# NOTE: class names, module names, and file paths will depend on which namespaces we decide to use.
# And the namespaces will depend on where we want them to live. There's no "right" answer for this.
# Just varying levels of "that makes sense" vs. "wtf?".
module Hyrax::Validations::FileRdfTypeValidation
extend ActiveSupport::Concern
included do
validate :validate_pcdm_file_rdf_types
end
def validate_pcdm_file_rdf_types
validates_with PcdmFileRdfTypeValidator
end
end
class Hyrax::Validators::PcdmFileRdfTypeValidator
def validate!()
# Read validation rules from config
# For each File within FileSet#files
# apply validation rules
end
end
# And then.. we'd add our new module to default FileSetBehavior within Hyrax
module Hyrax::FileSetBehavior
# this line is added
include Hyrax::Validations::FileRdfTypeValidation
end
# Or something along those lines...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment