Sha256: 84feb0386098dda4e860c502092cd7b44e112103edd77ba1d481fe705a1dd2d2
Contents?: true
Size: 1.18 KB
Versions: 27
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Hyrax ## # Applies a `VisibilityIntention` to a repository object. class VisibilityIntentionApplicator ## # @!attribute [rw] intention # @return [VisibilityIntention] attr_accessor :intention ## # @param [VisibilityIntention] intention def initialize(intention:) self.intention = intention end ## # @param [VisibilityIntention] intention # # @return [VisibilityIntentionApplicator] def self.apply(intention) new(intention: intention) end ## # @param [Object] model an object; this probably needs to be leasable, # embargoable, has visibility, and an AdminSet/PermissionTemplate. def apply_to(model:) if intention.wants_embargo? raise InvalidIntentionError unless intention.valid_embargo? model.apply_embargo(*intention.embargo_params) elsif intention.wants_lease? raise InvalidIntentionError unless intention.valid_lease? model.apply_lease(*intention.lease_params) else model.visibility = intention.visibility end end alias to apply_to class InvalidIntentionError < ArgumentError; end end end
Version data entries
27 entries across 27 versions & 1 rubygems