Sha256: a59e5a97dd985889f20dee12e3c1dca7ec95e4b6ed6b7b9b2f3336ba0902d7bc

Contents?: true

Size: 970 Bytes

Versions: 9

Compression:

Stored size: 970 Bytes

Contents

module Hyrax
  # Responsible for "applying" the various edit and read attributes to the given curation concern.
  # @see Hyrax::AdminSetService for release_date interaction
  class ApplyPermissionTemplateActor < Hyrax::Actors::AbstractActor
    def create(attributes)
      add_edit_users(attributes)
      next_actor.create(attributes)
    end

    protected

      def add_edit_users(attributes)
        return unless attributes[:admin_set_id].present?
        template = Hyrax::PermissionTemplate.find_by!(admin_set_id: attributes[:admin_set_id])
        curation_concern.edit_users += template.agent_ids_for(agent_type: 'user', access: 'manage')
        curation_concern.edit_groups += template.agent_ids_for(agent_type: 'group', access: 'manage')
        curation_concern.read_users += template.agent_ids_for(agent_type: 'user', access: 'view')
        curation_concern.read_groups += template.agent_ids_for(agent_type: 'group', access: 'view')
      end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyrax-1.1.1 app/actors/hyrax/apply_permission_template_actor.rb
hyrax-1.1.0 app/actors/hyrax/apply_permission_template_actor.rb
hyrax-1.0.5 app/actors/hyrax/apply_permission_template_actor.rb
hyrax-1.0.4 app/actors/hyrax/apply_permission_template_actor.rb
hyrax-1.0.3 app/actors/hyrax/apply_permission_template_actor.rb
hyrax-1.0.2 app/actors/hyrax/apply_permission_template_actor.rb
hyrax-1.0.1 app/actors/hyrax/apply_permission_template_actor.rb
hyrax-1.0.0.rc2 app/actors/hyrax/apply_permission_template_actor.rb
hyrax-1.0.0.rc1 app/actors/hyrax/apply_permission_template_actor.rb