Class: Hyrax::ResourceVisibilityPropagator

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

Overview

Propagates visibility from a valkyrie Work to its FileSets

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, embargo_manager: Hyrax::EmbargoManager, lease_manager: Hyrax::LeaseManager, persister: Hyrax.persister, queries: Hyrax.custom_queries) ⇒ ResourceVisibilityPropagator

Returns a new instance of ResourceVisibilityPropagator.

Parameters:

  • source (#visibility)

    the object to propagate visibility from



25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/hyrax/resource_visibility_propagator.rb', line 25

def initialize(source:,
               embargo_manager: Hyrax::EmbargoManager,
               lease_manager:   Hyrax::LeaseManager,
               persister:       Hyrax.persister,
               queries:         Hyrax.custom_queries)
  @persister       = persister
  @queries         = queries
  self.source      = source
  @embargo_manager = embargo_manager.new(resource: source)
  @lease_manager   = lease_manager.new(resource: source)
end

Instance Attribute Details

#embargo_managerHyrax::EmbargoManager (readonly)



21
22
23
# File 'app/services/hyrax/resource_visibility_propagator.rb', line 21

def embargo_manager
  @embargo_manager
end

#lease_managerHyrax::LeaseManager (readonly)

Returns:



21
# File 'app/services/hyrax/resource_visibility_propagator.rb', line 21

attr_reader :embargo_manager, :lease_manager, :persister, :queries

#persister#save (readonly)

Returns:

  • (#save)


21
# File 'app/services/hyrax/resource_visibility_propagator.rb', line 21

attr_reader :embargo_manager, :lease_manager, :persister, :queries

#queriesObject (readonly)

Returns the value of attribute queries.



21
# File 'app/services/hyrax/resource_visibility_propagator.rb', line 21

attr_reader :embargo_manager, :lease_manager, :persister, :queries

#source#visibility

Returns:

  • (#visibility)


10
11
12
# File 'app/services/hyrax/resource_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



41
42
43
44
45
46
47
48
49
50
# File 'app/services/hyrax/resource_visibility_propagator.rb', line 41

def propagate
  queries.find_child_file_sets(resource: source).each do |file_set|
    file_set.visibility = source.visibility
    embargo_manager.copy_embargo_to(target: file_set)
    lease_manager.copy_lease_to(target: file_set)

    file_set.permission_manager.acl.save
    persister.save(resource: file_set)
  end
end