Class: Hyrax::Transactions::Steps::ApplyVisibility Deprecated

Inherits:
Object
  • Object
show all
Includes:
Dry::Transaction::Operation
Defined in:
lib/hyrax/transactions/steps/apply_visibility.rb

Overview

Deprecated.

This is part of the legacy AF set of transaction steps for works. Transactions are not being used with AF works. This will be removed in 4.0.

A ‘dry-transaction` step that interprets visibility/lease/embargo from passed arguments.

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

#call(work, visibility: nil, release_date: nil, during: nil, after: nil) ⇒ Dry::Monads::Result

Returns ‘Failure` if there is no `PermissionTemplate` for the input; `Success(input)`, otherwise.

Parameters:

  • work (Hyrax::WorkBehavior)
  • visibility (String) (defaults to: nil)
  • release_date (String) (defaults to: nil)
  • during (String) (defaults to: nil)
  • after (String) (defaults to: nil)

Returns:

  • (Dry::Monads::Result)

    ‘Failure` if there is no `PermissionTemplate` for the input; `Success(input)`, otherwise.

Since:

  • 3.0.0



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hyrax/transactions/steps/apply_visibility.rb', line 24

def call(work, visibility: nil, release_date: nil, during: nil, after: nil)
  return Success(work) if visibility.blank?

  intention = Hyrax::VisibilityIntention.new(visibility: visibility,
                                             release_date: release_date,
                                             during: during,
                                             after: after)

  Hyrax::VisibilityIntentionApplicator.apply(intention).to(model: work)

  Success(work)
rescue Hyrax::VisibilityIntentionApplicator::InvalidIntentionError => err
  Failure(err)
end