Class: Hyrax::Transactions::Steps::CheckForDefaultAdminSet

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

Overview

Validates non-defaultness of the AdministrativeSet; gives ‘Success` when not the default and `Failure` otherwise.

Use this step to guard against destroying the default AdminSet.

Since:

  • 2.4.0

Instance Method Summary collapse

Constructor Details

#initialize(query_service: Hyrax.query_service) ⇒ CheckForDefaultAdminSet

Returns a new instance of CheckForDefaultAdminSet.

Parameters:

  • query_service (#find_inverse_references_by) (defaults to: Hyrax.query_service)

Since:

  • 2.4.0



17
18
19
# File 'lib/hyrax/transactions/steps/check_for_default_admin_set.rb', line 17

def initialize(query_service: Hyrax.query_service)
  @query_service = query_service
end

Instance Method Details

#call(admin_set) ⇒ Dry::Monads::Result

Parameters:

Returns:

  • (Dry::Monads::Result)

Since:

  • 2.4.0



25
26
27
28
# File 'lib/hyrax/transactions/steps/check_for_default_admin_set.rb', line 25

def call(admin_set)
  return Failure["Administrative set cannot be deleted as it is the default set", admin_set] if admin_set.id == Hyrax.config.default_admin_set_id
  Success(admin_set)
end