Sha256: 86c37e73dc6dcd52848daea8154a6fb8a7c4ef238616064fab15900ab627090c

Contents?: true

Size: 722 Bytes

Versions: 18

Compression:

Stored size: 722 Bytes

Contents

# A job to apply work permissions to all contained files set
#
class InheritPermissionsJob < ActiveJob::Base
  # 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

18 entries across 18 versions & 3 rubygems

Version Path
hyrax-1.1.1 app/jobs/inherit_permissions_job.rb
hyrax-1.1.0 app/jobs/inherit_permissions_job.rb
sufia-7.4.1 app/jobs/inherit_permissions_job.rb
hyrax-1.0.5 app/jobs/inherit_permissions_job.rb
sufia-7.4.0 app/jobs/inherit_permissions_job.rb
hyrax-1.0.4 app/jobs/inherit_permissions_job.rb
hyrax-1.0.3 app/jobs/inherit_permissions_job.rb
hyrax-1.0.2 app/jobs/inherit_permissions_job.rb
hyrax-1.0.1 app/jobs/inherit_permissions_job.rb
hyrax-1.0.0.rc2 app/jobs/inherit_permissions_job.rb
sufia-7.3.1 app/jobs/inherit_permissions_job.rb
hyrax-1.0.0.rc1 app/jobs/inherit_permissions_job.rb
sufia-7.3.0 app/jobs/inherit_permissions_job.rb
sufia-7.3.0.rc3 app/jobs/inherit_permissions_job.rb
sufia-7.3.0.rc2 app/jobs/inherit_permissions_job.rb
sufia-7.3.0.rc1 app/jobs/inherit_permissions_job.rb
test_hyrax-0.0.1.alpha app/jobs/inherit_permissions_job.rb
sufia-7.2.0 app/jobs/inherit_permissions_job.rb