Class: Hyrax::Actors::FileActor
- Inherits:
-
Object
- Object
- Hyrax::Actors::FileActor
- Defined in:
- app/actors/hyrax/actors/file_actor.rb
Overview
Spawns asynchronous jobs
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.
-
#use_valkyrie ⇒ Object
readonly
Returns the value of attribute use_valkyrie.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#ingest_file(io) ⇒ CharacterizeJob, FalseClass
Persists file as part of file_set and spawns async job to characterize and create derivatives.
-
#initialize(file_set, relation, user, use_valkyrie: Hyrax.config.query_index_from_valkyrie) ⇒ FileActor
constructor
A new instance of FileActor.
-
#revert_to(revision_id) ⇒ CharacterizeJob, FalseClass
Reverts file and spawns async job to characterize and create derivatives.
Constructor Details
#initialize(file_set, relation, user, use_valkyrie: Hyrax.config.query_index_from_valkyrie) ⇒ FileActor
Returns a new instance of FileActor.
14 15 16 17 18 19 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 14 def initialize(file_set, relation, user, use_valkyrie: Hyrax.config.query_index_from_valkyrie) @use_valkyrie = use_valkyrie @file_set = file_set @relation = normalize_relation(relation) @user = user end |
Instance Attribute Details
#file_set ⇒ Object (readonly)
Returns the value of attribute file_set.
9 10 11 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 9 def file_set @file_set end |
#relation ⇒ Object (readonly)
Returns the value of attribute relation.
9 10 11 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 9 def relation @relation end |
#use_valkyrie ⇒ Object (readonly)
Returns the value of attribute use_valkyrie.
9 10 11 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 9 def use_valkyrie @use_valkyrie end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
9 10 11 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 9 def user @user end |
Instance Method Details
#==(other) ⇒ Object
FileSet comparison is limited to IDs, but this should be sufficient, given that most operations here are on the other side of async retrieval in Jobs (based solely on ID).
44 45 46 47 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 44 def ==(other) return false unless other.is_a?(self.class) file_set.id == other.file_set.id && relation == other.relation && user == other.user end |
#ingest_file(io) ⇒ CharacterizeJob, FalseClass
create a job to monitor the temp directory (or in a multi-worker system, directories!) to prune old files that have made it into the repo
Instead of calling this method, use IngestJob to avoid synchronous execution cost
Persists file as part of file_set and spawns async job to characterize and create derivatives.
27 28 29 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 27 def ingest_file(io) use_valkyrie ? perform_ingest_file_through_valkyrie(io) : perform_ingest_file_through_active_fedora(io) end |
#revert_to(revision_id) ⇒ CharacterizeJob, FalseClass
Reverts file and spawns async job to characterize and create derivatives.
34 35 36 37 38 39 40 |
# File 'app/actors/hyrax/actors/file_actor.rb', line 34 def revert_to(revision_id) repository_file = repository_file.restore_version(revision_id) return false unless file_set.save create_version(repository_file, user) CharacterizeJob.perform_later(file_set, repository_file.id) end |