Class: Hyrax::Actors::CreateWithFilesActor

Inherits:
AbstractActor show all
Defined in:
app/actors/hyrax/actors/create_with_files_actor.rb

Overview

Creates a work and attaches files to the work

Direct Known Subclasses

CreateWithFilesOrderedMembersActor

Instance Attribute Summary

Attributes inherited from AbstractActor

#next_actor

Instance Method Summary collapse

Methods inherited from AbstractActor

#initialize

Constructor Details

This class inherits a constructor from Hyrax::Actors::AbstractActor

Instance Method Details

#create(env) ⇒ Boolean

Returns true if create was successful.

Parameters:

Returns:

  • (Boolean)

    true if create was successful



8
9
10
11
12
13
14
15
16
17
# File 'app/actors/hyrax/actors/create_with_files_actor.rb', line 8

def create(env)
  uploaded_file_ids = filter_file_ids(env.attributes.delete(:uploaded_files))
  files             = uploaded_files(uploaded_file_ids)
  # get a current copy of attributes, to protect against future mutations
  attributes        = env.attributes.clone

  validate_files(files, env) &&
    next_actor.create(env) &&
    attach_files(files, env.curation_concern, attributes)
end

#update(env) ⇒ Boolean

Returns true if update was successful.

Parameters:

Returns:

  • (Boolean)

    true if update was successful



21
22
23
24
25
26
27
28
29
30
# File 'app/actors/hyrax/actors/create_with_files_actor.rb', line 21

def update(env)
  uploaded_file_ids = filter_file_ids(env.attributes.delete(:uploaded_files))
  files             = uploaded_files(uploaded_file_ids)
  # get a current copy of attributes, to protect against future mutations
  attributes        = env.attributes.clone

  validate_files(files, env) &&
    next_actor.update(env) &&
    attach_files(files, env.curation_concern, attributes)
end