Sha256: e4ef1f2640f215ccb1cbe3174095beb994a283a576a298fbcc330f020c13ac53

Contents?: true

Size: 971 Bytes

Versions: 22

Compression:

Stored size: 971 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module Transactions
    module Steps
      ##
      # A `dry-transcation` step that applies permission templates from a
      # collection type on a given collection.
      #
      # @since 3.2.0
      class ApplyCollectionTypePermissions
        include Dry::Monads[:result]

        ##
        # @param [Hyrax::PcdmCollection] collection with a collection type gid
        # @param user [User] the user that created the collection
        #
        # @return [Dry::Monads::Result]
        def call(collection, user: nil)
          Hyrax::Collections::PermissionsCreateService.create_default(collection: collection,
                                                                      creating_user: user)
          Success(collection)
        rescue URI::InvalidURIError => err
          # will be raised if the collection_type_gid is invalid or doesn't exist
          Failure(err)
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-5.0.4 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-5.0.3 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-5.0.2 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-5.0.1 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-5.0.0 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-5.0.0.rc3 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-5.0.0.rc2 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-5.0.0.rc1 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-3.6.0 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-4.0.0 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-4.0.0.rc3 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-4.0.0.rc2 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-4.0.0.rc1 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-3.5.0 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-4.0.0.beta2 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-3.4.2 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-4.0.0.beta1 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-3.4.1 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb
hyrax-3.4.0 lib/hyrax/transactions/steps/apply_collection_type_permissions.rb