Class: CurationConcerns::FileActor
- Inherits:
-
Object
- Object
- CurationConcerns::FileActor
- Defined in:
- app/actors/curation_concerns/file_actor.rb
Overview
actions for a file identified by file_set and relation (maps to use predicate)
Instance Attribute Summary collapse
-
#file_set ⇒ Object
readonly
Returns the value of attribute file_set.
-
#relation ⇒ Object
readonly
Returns the value of attribute relation.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#ingest_file(file) ⇒ Object
Puts the uploaded content into a staging directory.
-
#initialize(file_set, relation, user) ⇒ FileActor
constructor
A new instance of FileActor.
- #revert_to(revision_id) ⇒ Object
Constructor Details
#initialize(file_set, relation, user) ⇒ FileActor
Returns a new instance of FileActor.
9 10 11 12 13 |
# File 'app/actors/curation_concerns/file_actor.rb', line 9 def initialize(file_set, relation, user) @file_set = file_set @relation = relation @user = user end |
Instance Attribute Details
#file_set ⇒ Object (readonly)
Returns the value of attribute file_set.
4 5 6 |
# File 'app/actors/curation_concerns/file_actor.rb', line 4 def file_set @file_set end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
4 5 6 |
# File 'app/actors/curation_concerns/file_actor.rb', line 4 def relation @relation end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'app/actors/curation_concerns/file_actor.rb', line 4 def user @user end |
Instance Method Details
#ingest_file(file) ⇒ Object
Puts the uploaded content into a staging directory. Then kicks off a job to characterize and create derivatives with this on disk variant. Simultaneously moving a preservation copy to the repostiory. TODO: create a job to monitor this directory and prune old files that have made it to the repo
21 22 23 24 25 26 27 |
# File 'app/actors/curation_concerns/file_actor.rb', line 21 def ingest_file(file) working_file = copy_file_to_working_directory(file, file_set.id) mime_type = file.respond_to?(:content_type) ? file.content_type : nil IngestFileJob.perform_later(file_set, working_file, mime_type, user.user_key, relation) make_derivative(file_set, working_file) true end |
#revert_to(revision_id) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/actors/curation_concerns/file_actor.rb', line 29 def revert_to(revision_id) repository_file = file_set.send(relation.to_sym) repository_file.restore_version(revision_id) return false unless file_set.save CurationConcerns::VersioningService.create(repository_file, user) # Retrieve a copy of the orginal file from the repository working_file = copy_repository_resource_to_working_directory(repository_file) make_derivative(file_set, working_file) true end |