Class: Hyrax::Transactions::Steps::ApplyPermissionTemplate
- Inherits:
-
Object
- Object
- Hyrax::Transactions::Steps::ApplyPermissionTemplate
- Defined in:
- lib/hyrax/transactions/steps/apply_permission_template.rb
Overview
Note:
by design, this step should succeed even if for some reason a permission template could not be applied. it’s better to complete the rest of the creation process with missing ACL grants than to crash and miss other crucial steps.
A ‘dry-transcation` step that applies a permission template to a saved object.
Instance Method Summary collapse
Instance Method Details
#call(object) ⇒ Dry::Monads::Result
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/hyrax/transactions/steps/apply_permission_template.rb', line 22 def call(object) template = Hyrax::PermissionTemplate.find_by(source_id: object&.admin_set_id) if template.blank? Hyrax.logger.info("At create time, #{object} doesn't have a " \ "PermissionTemplate, which it should have via " \ "AdministrativeSet #{object&.admin_set_id}). " \ "Continuing to create this object anyway.") return Success(object) end Hyrax::PermissionTemplateApplicator.apply(template).to(model: object) && Success(object) end |