Class: Hyrax::Transactions::Steps::SetCollectionTypeGid

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

Overview

A step that sets the `#collection_type_gid` in the change set.

Since:

  • 3.2.0

Instance Method Summary collapse

Instance Method Details

#call(change_set, collection_type_gid: default_collection_type_gid) ⇒ Dry::Monads::Result

Returns `Failure` if there is no `collection_type_gid` or it can't be set to the default for the input; `Success(input)`, otherwise.

Parameters:

  • change_set (Hyrax::ChangeSet)
  • collection_type_gid (URI::GID) (defaults to: default_collection_type_gid)

    global id for the collection type

Returns:

  • (Dry::Monads::Result)

    `Failure` if there is no `collection_type_gid` or it can't be set to the default for the input; `Success(input)`, otherwise.

Since:

  • 3.2.0


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

def call(change_set, collection_type_gid: default_collection_type_gid)
  return Failure[:no_collection_type_gid, collection] unless
    change_set.respond_to?(:collection_type_gid=)
  return Success(change_set) if
    change_set.collection_type_gid.present?

  change_set.collection_type_gid = collection_type_gid
  Success(change_set)
end