Class: Hyrax::Actors::FileActor
- Inherits:
-
Object
- Object
- Hyrax::Actors::FileActor
- Defined in:
- app/actors/hyrax/actors/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, asynchronous) ⇒ 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.
10 11 12 13 14 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 10 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.
5 6 7 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 5 def file_set @file_set end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
5 6 7 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 5 def relation @relation end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
5 6 7 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 5 def user @user end |
Instance Method Details
#ingest_file(file, asynchronous) ⇒ Object
Puts the uploaded content into a staging directory. Then kicks off a job to ingest the file into the repository, then characterize and create derivatives with this on disk variant. TODO: create a job to monitor this directory and prune old files that have made it to the repo
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 23 def ingest_file(file, asynchronous) method = if asynchronous :perform_later else :perform_now end IngestFileJob.send(method, file_set, working_file(file), user, (file)) true end |
#revert_to(revision_id) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 38 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 Hyrax::VersioningService.create(repository_file, user) # Characterize the original file from the repository CharacterizeJob.perform_later(file_set, repository_file.id) true end |