Class: Hydra::AccessControls::Embargo
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- Hydra::AccessControls::Embargo
- Defined in:
- app/models/hydra/access_controls/embargo.rb
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#deactivate! ⇒ Object
Deactivates the embargo and logs a message to the embargo_history property.
- #embargo_release_date=(date) ⇒ Object
- #to_hash ⇒ Object
Instance Method Details
#active? ⇒ Boolean
13 14 15 |
# File 'app/models/hydra/access_controls/embargo.rb', line 13 def active? (.present? && Date.today < ) end |
#deactivate! ⇒ Object
Deactivates the embargo and logs a message to the embargo_history property
18 19 20 21 22 23 24 25 26 |
# File 'app/models/hydra/access_controls/embargo.rb', line 18 def deactivate! return unless = active? ? "active" : "expired" = (, Date.today, , , ) self. = nil self. = nil self. = nil self. += [] end |
#embargo_release_date=(date) ⇒ Object
8 9 10 11 |
# File 'app/models/hydra/access_controls/embargo.rb', line 8 def (date) date = DateTime.parse(date) if date.kind_of?(String) super(date) end |
#to_hash ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'app/models/hydra/access_controls/embargo.rb', line 28 def to_hash {}.tap do |doc| date_field_name = Hydra.config...release_date.sub(/_dtsi/, '') ActiveFedora::Indexing::Inserter.insert_field(doc, date_field_name, , :stored_sortable) doc[ActiveFedora.index_field_mapper.solr_name("visibility_during_embargo", :symbol)] = unless .nil? doc[ActiveFedora.index_field_mapper.solr_name("visibility_after_embargo", :symbol)] = unless .nil? doc[ActiveFedora.index_field_mapper.solr_name("embargo_history", :symbol)] = unless .nil? end end |