Class: Hyrax::Actors::CreateWithRemoteFilesActor

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

Overview

If there is a key ‘:remote_files’ in the attributes, it attaches the files at the specified URIs to the work. e.g.:

attributes[:remote_files] = filenames.map do |name|
  { url: "https://example.com/file/#{name}", file_name: name }
end

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



11
12
13
14
# File 'app/actors/hyrax/actors/create_with_remote_files_actor.rb', line 11

def create(env)
  remote_files = env.attributes.delete(:remote_files)
  next_actor.create(env) && attach_files(env, remote_files)
end

#update(env) ⇒ Boolean

Returns true if update was successful.

Parameters:

Returns:

  • (Boolean)

    true if update was successful



18
19
20
21
# File 'app/actors/hyrax/actors/create_with_remote_files_actor.rb', line 18

def update(env)
  remote_files = env.attributes.delete(:remote_files)
  next_actor.update(env) && attach_files(env, remote_files)
end