Class: Hyrax::FileSetVisibilityPropagator

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/file_set_visibility_propagator.rb

Overview

Propagates visibility from a given Work to its FileSets

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:) ⇒ FileSetVisibilityPropagator

Returns a new instance of FileSetVisibilityPropagator.

Parameters:

  • source (#visibility)

    the object to propagate visibility from



14
15
16
# File 'app/services/hyrax/file_set_visibility_propagator.rb', line 14

def initialize(source:)
  self.source = source
end

Instance Attribute Details

#source#visibility

Returns:

  • (#visibility)


10
11
12
# File 'app/services/hyrax/file_set_visibility_propagator.rb', line 10

def source
  @source
end

Instance Method Details

#propagatevoid

This method returns an undefined value.

Raises:

  • (RuntimeError)

    if visibility propagation fails



22
23
24
25
26
27
28
29
# File 'app/services/hyrax/file_set_visibility_propagator.rb', line 22

def propagate
  source.file_sets.each do |file|
    file.visibility = source.visibility # visibility must come first, because it can clear an embargo/lease
    copy_visibility_modifier(source: source, file: file, modifier: :lease)
    copy_visibility_modifier(source: source, file: file, modifier: :embargo)
    file.save!
  end
end