Class: Hyrax::VisibilityIntentionApplicator
- Inherits:
-
Object
- Object
- Hyrax::VisibilityIntentionApplicator
- Defined in:
- app/services/hyrax/visibility_intention_applicator.rb
Overview
Applies a ‘VisibilityIntention` to a repository object.
Defined Under Namespace
Classes: InvalidIntentionError
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
- #apply_to(model:) ⇒ Object (also: #to)
-
#initialize(intention:) ⇒ VisibilityIntentionApplicator
constructor
A new instance of VisibilityIntentionApplicator.
Constructor Details
#initialize(intention:) ⇒ VisibilityIntentionApplicator
Returns a new instance of VisibilityIntentionApplicator.
13 14 15 |
# File 'app/services/hyrax/visibility_intention_applicator.rb', line 13 def initialize(intention:) self.intention = intention end |
Instance Attribute Details
#intention ⇒ VisibilityIntention
9 10 11 |
# File 'app/services/hyrax/visibility_intention_applicator.rb', line 9 def intention @intention end |
Class Method Details
.apply(intention) ⇒ VisibilityIntentionApplicator
21 22 23 |
# File 'app/services/hyrax/visibility_intention_applicator.rb', line 21 def self.apply(intention) new(intention: intention) end |
Instance Method Details
#apply_to(model:) ⇒ Object Also known as: to
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/services/hyrax/visibility_intention_applicator.rb', line 28 def apply_to(model:) if intention. raise InvalidIntentionError unless intention. model.(*intention.) elsif intention.wants_lease? raise InvalidIntentionError unless intention.valid_lease? model.apply_lease(*intention.lease_params) else model.visibility = intention.visibility end end |