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

Browse everything may also return a local file. And although it's in the url property, it may have spaces, and not be a valid URI.

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


14
15
16
17
# File 'app/actors/hyrax/actors/create_with_remote_files_actor.rb', line 14

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


21
22
23
24
# File 'app/actors/hyrax/actors/create_with_remote_files_actor.rb', line 21

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