Sha256: 145bfef83fd6460e97334bde41df8ce6084d0c93e810e389383d3b12038f5b9e

Contents?: true

Size: 728 Bytes

Versions: 48

Compression:

Stored size: 728 Bytes

Contents

# A job to apply work permissions to all contained files set
#
class InheritPermissionsJob < Hyrax::ApplicationJob
  # Perform the copy from the work to the contained filesets
  #
  # @param work containing access level and filesets
  def perform(work)
    work.file_sets.each do |file|
      attribute_map = work.permissions.map(&:to_hash)

      # copy and removed access to the new access with the delete flag
      file.permissions.map(&:to_hash).each do |perm|
        unless attribute_map.include?(perm)
          perm[:_destroy] = true
          attribute_map << perm
        end
      end

      # apply the new and deleted attributes
      file.permissions_attributes = attribute_map
      file.save!
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/jobs/inherit_permissions_job.rb
hyrax-2.9.5 app/jobs/inherit_permissions_job.rb
hyrax-2.9.4 app/jobs/inherit_permissions_job.rb
hyrax-2.9.3 app/jobs/inherit_permissions_job.rb
hyrax-2.9.2 app/jobs/inherit_permissions_job.rb
hyrax-2.9.1 app/jobs/inherit_permissions_job.rb
hyrax-2.9.0 app/jobs/inherit_permissions_job.rb
hyrax-2.8.0 app/jobs/inherit_permissions_job.rb
hyrax-2.7.2 app/jobs/inherit_permissions_job.rb
hyrax-2.7.1 app/jobs/inherit_permissions_job.rb
hyrax-2.7.0 app/jobs/inherit_permissions_job.rb
hyrax-2.6.0 app/jobs/inherit_permissions_job.rb
hyrax-3.0.0.pre.rc1 app/jobs/inherit_permissions_job.rb
hyrax-3.0.0.pre.beta3 app/jobs/inherit_permissions_job.rb
hyrax-2.5.1 app/jobs/inherit_permissions_job.rb
hyrax-2.5.0 app/jobs/inherit_permissions_job.rb
hyrax-3.0.0.pre.beta2 app/jobs/inherit_permissions_job.rb
hyrax-2.4.1 app/jobs/inherit_permissions_job.rb
hyrax-3.0.0.pre.beta1 app/jobs/inherit_permissions_job.rb
hyrax-2.4.0 app/jobs/inherit_permissions_job.rb