Class: Hyrax::VisibilityIntention
- Inherits:
-
Object
- Object
- Hyrax::VisibilityIntention
- Defined in:
- app/services/hyrax/visibility_intention.rb
Overview
Provides tools for interpreting form input as a visibility.
Direct Known Subclasses
Constant Summary collapse
- PUBLIC =
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
- PRIVATE =
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
- LEASE_REQUEST =
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE
- EMBARGO_REQUEST =
Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO
Instance Attribute Summary collapse
-
#after ⇒ String
The visibility requested after the embargo/lease release.
-
#during ⇒ String
The visibility requested while the embargo/lease is in effect.
- #release_date ⇒ String
- #visibility ⇒ String
Instance Method Summary collapse
-
#embargo_params ⇒ Array
The parameters for the requested embargo.
-
#initialize(visibility: PRIVATE, release_date: nil, during: nil, after: nil) ⇒ VisibilityIntention
constructor
A new instance of VisibilityIntention.
-
#lease_params ⇒ Array
The parameters for the requested embargo.
- #valid_embargo? ⇒ Boolean
- #valid_lease? ⇒ Boolean
- #wants_embargo? ⇒ Boolean
- #wants_lease? ⇒ Boolean
Constructor Details
#initialize(visibility: PRIVATE, release_date: nil, during: nil, after: nil) ⇒ VisibilityIntention
Returns a new instance of VisibilityIntention.
29 30 31 32 33 34 |
# File 'app/services/hyrax/visibility_intention.rb', line 29 def initialize(visibility: PRIVATE, release_date: nil, during: nil, after: nil) self.after = after self.during = during self.release_date = release_date self.visibility = visibility end |
Instance Attribute Details
#after ⇒ String
Returns the visibility requested after the embargo/lease release.
22 23 24 |
# File 'app/services/hyrax/visibility_intention.rb', line 22 def after @after end |
#during ⇒ String
Returns the visibility requested while the embargo/lease is in effect.
22 |
# File 'app/services/hyrax/visibility_intention.rb', line 22 attr_accessor :after, :during, :release_date, :visibility |
#release_date ⇒ String
22 |
# File 'app/services/hyrax/visibility_intention.rb', line 22 attr_accessor :after, :during, :release_date, :visibility |
#visibility ⇒ String
22 |
# File 'app/services/hyrax/visibility_intention.rb', line 22 attr_accessor :after, :during, :release_date, :visibility |
Instance Method Details
#embargo_params ⇒ Array
Returns the parameters for the requested embargo.
38 39 40 41 42 43 |
# File 'app/services/hyrax/visibility_intention.rb', line 38 def return [] unless raise ArgumentError unless [release_date, (during || PRIVATE), (after || PUBLIC)] end |
#lease_params ⇒ Array
Returns the parameters for the requested embargo.
47 48 49 50 51 52 |
# File 'app/services/hyrax/visibility_intention.rb', line 47 def lease_params return [] unless wants_lease? raise ArgumentError unless valid_lease? [release_date, (during || PUBLIC), (after || PRIVATE)] end |
#valid_embargo? ⇒ Boolean
56 57 58 |
# File 'app/services/hyrax/visibility_intention.rb', line 56 def && release_date.present? && a_valid_date?(release_date) end |
#valid_lease? ⇒ Boolean
68 69 70 |
# File 'app/services/hyrax/visibility_intention.rb', line 68 def valid_lease? wants_lease? && release_date.present? && a_valid_date?(release_date) end |
#wants_embargo? ⇒ Boolean
62 63 64 |
# File 'app/services/hyrax/visibility_intention.rb', line 62 def visibility == EMBARGO_REQUEST end |
#wants_lease? ⇒ Boolean
74 75 76 |
# File 'app/services/hyrax/visibility_intention.rb', line 74 def wants_lease? visibility == LEASE_REQUEST end |