Class: Hyrax::Transactions::Steps::ApplyCollectionTypePermissions

Inherits:
Object
  • Object
show all
Defined in:
lib/hyrax/transactions/steps/apply_collection_type_permissions.rb

Overview

A `dry-transcation` step that applies permission templates from a collection type on a given collection.

Since:

  • 3.2.0

Instance Method Summary collapse

Instance Method Details

#call(collection, user: nil) ⇒ Dry::Monads::Result

Parameters:

  • collection (Hyrax::PcdmCollection)

    with a collection type gid

  • user (User) (defaults to: nil)

    the user that created the collection

Returns:

  • (Dry::Monads::Result)

Since:

  • 3.2.0


18
19
20
21
22
23
24
25
# File 'lib/hyrax/transactions/steps/apply_collection_type_permissions.rb', line 18

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