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

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



7
8
9
10
11
# File 'app/actors/hyrax/actors/create_with_files_actor.rb', line 7

def create(env)
  uploaded_file_ids = filter_file_ids(env.attributes.delete(:uploaded_files))
  files = uploaded_files(uploaded_file_ids)
  validate_files(files, env) && next_actor.create(env) && attach_files(files, env)
end

#update(env) ⇒ Boolean

Returns true if update was successful.

Parameters:

Returns:

  • (Boolean)

    true if update was successful



15
16
17
18
19
# File 'app/actors/hyrax/actors/create_with_files_actor.rb', line 15

def update(env)
  uploaded_file_ids = filter_file_ids(env.attributes.delete(:uploaded_files))
  files = uploaded_files(uploaded_file_ids)
  validate_files(files, env) && next_actor.update(env) && attach_files(files, env)
end