Sha256: e94de301ec652535b09fc616e54d547f80fab3feee2618924b34275d7e433b26
Contents?: true
Size: 975 Bytes
Versions: 11
Compression:
Stored size: 975 Bytes
Contents
# frozen_string_literal: true module Hyrax module Transactions module Steps ## # A `dry-transcation` step that applies permission templates for a set of # collections on a given work. # # @since 3.0.0 class ApplyCollectionPermissionTemplate include Dry::Transaction::Operation ## # @param [Hyrax::WorkBehavior] work # @param [Array<#permision_template>] collections a list of collections for which # permission templates should be applied # # @return [Dry::Monads::Result] def call(work, collections: []) collections.each do |collection| template = Hyrax::PermissionTemplate.find_by!(source_id: collection.id) Hyrax::PermissionTemplateApplicator.apply(template).to(model: work) end Success(work) rescue ActiveRecord::RecordNotFound => err Failure(err) end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems