Class: Hyrax::Actors::InterpretVisibilityActor::Intention
- Inherits:
-
Object
- Object
- Hyrax::Actors::InterpretVisibilityActor::Intention
- Defined in:
- app/actors/hyrax/actors/interpret_visibility_actor.rb
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/hyrax/actors/interpret_visibility_actor.rb', line 5 def initialize(attributes) @attributes = attributes end |
Instance Method Details
#embargo_params ⇒ Object
46 47 48 49 50 |
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 46 def [:embargo_release_date, :visibility_during_embargo, :visibility_after_embargo].map { |key| @attributes[key] } end |
#lease_params ⇒ Object
40 41 42 43 44 |
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 40 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 |
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 12 def sanitize_params if valid_lease? sanitize_lease_params elsif elsif !wants_lease? && ! sanitize_unrestricted_params else @attributes end end |
#valid_embargo? ⇒ Boolean
36 37 38 |
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 36 def && @attributes[:embargo_release_date].present? end |
#valid_lease? ⇒ Boolean
32 33 34 |
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 32 def valid_lease? wants_lease? && @attributes[:lease_expiration_date].present? end |
#wants_embargo? ⇒ Boolean
28 29 30 |
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 28 def visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO end |
#wants_lease? ⇒ Boolean
24 25 26 |
# File 'app/actors/hyrax/actors/interpret_visibility_actor.rb', line 24 def wants_lease? visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE end |