Class: CurationConcerns::Actors::FileActor

Inherits:
Object
  • Object
show all
Defined in:
app/actors/curation_concerns/actors/file_actor.rb

Overview

actions for a file identified by file_set and relation (maps to use predicate)

Since:

  • 0.14.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_set, relation, user) ⇒ FileActor

Returns a new instance of FileActor.

Parameters:

  • file_set (FileSet)

    the parent FileSet

  • relation (String)

    the type/use for the file.

  • user (User)

    the user to record as the Agent acting upon the file

Since:

  • 0.14.0



10
11
12
13
14
# File 'app/actors/curation_concerns/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_setObject (readonly)

Since:

  • 0.14.0



5
6
7
# File 'app/actors/curation_concerns/actors/file_actor.rb', line 5

def file_set
  @file_set
end

#relationObject (readonly)

Since:

  • 0.14.0



5
6
7
# File 'app/actors/curation_concerns/actors/file_actor.rb', line 5

def relation
  @relation
end

#userObject (readonly)

Since:

  • 0.14.0



5
6
7
# File 'app/actors/curation_concerns/actors/file_actor.rb', line 5

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 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

Parameters:

  • file (File, ActionDigest::HTTP::UploadedFile, Tempfile)

    the file to save in the repository

Since:

  • 0.14.0



22
23
24
25
26
27
28
29
# File 'app/actors/curation_concerns/actors/file_actor.rb', line 22

def ingest_file(file)
  IngestFileJob.perform_later(
    file_set,
    working_file(file),
    user,
    ingest_options(file))
  true
end

#revert_to(revision_id) ⇒ Object

Since:

  • 0.14.0



31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/actors/curation_concerns/actors/file_actor.rb', line 31

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)

  # Characterize the original file from the repository
  CharacterizeJob.perform_later(file_set, repository_file.id)
  true
end