Class: Hyrax::Actors::CreateWithFilesActor
- Inherits:
-
AbstractActor
- Object
- AbstractActor
- Hyrax::Actors::CreateWithFilesActor
- Defined in:
- app/actors/hyrax/actors/create_with_files_actor.rb
Overview
Creates a work and attaches files to the work
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from AbstractActor
Instance Method Summary collapse
-
#create(env) ⇒ Boolean
True if create was successful.
-
#update(env) ⇒ Boolean
True if update was successful.
Methods inherited from AbstractActor
Constructor Details
This class inherits a constructor from Hyrax::Actors::AbstractActor
Instance Method Details
#create(env) ⇒ Boolean
Returns 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.
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 |