Class: CurationConcerns::Actors::InterpretVisibilityActor::Intention
- Inherits:
-
Object
- Object
- CurationConcerns::Actors::InterpretVisibilityActor::Intention
- Defined in:
- app/actors/curation_concerns/actors/interpret_visibility_actor.rb
Overview
Instance Method Summary collapse
- #embargo_params ⇒ Object
-
#initialize(attributes) ⇒ Intention
constructor
A new instance of Intention.
- #lease_params ⇒ Object
-
#sanitize_params ⇒ Object
returns a copy of attributes with the necessary params removed If the lease or embargo is valid, or if they selected something besides lease or embargo, remove all the params.
- #valid_embargo? ⇒ Boolean
- #valid_lease? ⇒ Boolean
- #wants_embargo? ⇒ Boolean
- #wants_lease? ⇒ Boolean
Constructor Details
#initialize(attributes) ⇒ Intention
Returns a new instance of Intention.
5 6 7 |
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 5 def initialize(attributes) @attributes = attributes end |
Instance Method Details
#embargo_params ⇒ Object
57 58 59 60 61 |
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 57 def [:embargo_release_date, :visibility_during_embargo, :visibility_after_embargo].map { |key| @attributes[key] } end |
#lease_params ⇒ Object
51 52 53 54 55 |
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 51 def lease_params [:lease_expiration_date, :visibility_during_lease, :visibility_after_lease].map { |key| @attributes[key] } end |
#sanitize_params ⇒ Object
returns a copy of attributes with the necessary params removed If the lease or embargo is valid, or if they selected something besides lease or embargo, remove all the params.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 12 def sanitize_params if valid_lease? @attributes.except(:visibility, :embargo_release_date, :visibility_during_embargo, :visibility_after_embargo) elsif @attributes.except(:visibility, :lease_expiration_date, :visibility_during_lease, :visibility_after_lease) elsif !wants_lease? && ! @attributes.except(:lease_expiration_date, :visibility_during_lease, :visibility_after_lease, :embargo_release_date, :visibility_during_embargo, :visibility_after_embargo) else @attributes end end |
#valid_embargo? ⇒ Boolean
47 48 49 |
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 47 def && @attributes[:embargo_release_date].present? end |
#valid_lease? ⇒ Boolean
43 44 45 |
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 43 def valid_lease? wants_lease? && @attributes[:lease_expiration_date].present? end |
#wants_embargo? ⇒ Boolean
39 40 41 |
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 39 def visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO end |
#wants_lease? ⇒ Boolean
35 36 37 |
# File 'app/actors/curation_concerns/actors/interpret_visibility_actor.rb', line 35 def wants_lease? visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE end |