Class: Hyrax::GrantReadJob

Inherits:
ApplicationJob show all
Includes:
PermissionJobBehavior
Defined in:
app/jobs/hyrax/grant_read_job.rb

Overview

Grants the user's read access on the provided FileSet

Instance Method Summary collapse

Instance Method Details

#perform(file_set_id, user_key, use_valkyrie: Hyrax.config.use_valkyrie?) ⇒ Object

Parameters:

  • file_set_id (String)

    the identifier of the object to grant access to

  • user_key (String)

    the user to add

  • use_valkyrie (Boolean) (defaults to: Hyrax.config.use_valkyrie?)

    use valkyrie resources for this operation?


9
10
11
12
13
14
15
16
17
# File 'app/jobs/hyrax/grant_read_job.rb', line 9

def perform(file_set_id, user_key, use_valkyrie: Hyrax.config.use_valkyrie?)
  if use_valkyrie
    acl(file_set_id).grant(:read).to(user(user_key)).save
  else
    file_set = ::FileSet.find(file_set_id)
    file_set.read_users += [user_key]
    file_set.save!
  end
end