Class: Hydra::AccessControls::Lease
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- Hydra::AccessControls::Lease
- Defined in:
- app/models/hydra/access_controls/lease.rb
Instance Method Summary collapse
Instance Method Details
#active? ⇒ Boolean
13 14 15 |
# File 'app/models/hydra/access_controls/lease.rb', line 13 def active? lease_expiration_date.present? && Date.today < lease_expiration_date end |
#deactivate! ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'app/models/hydra/access_controls/lease.rb', line 17 def deactivate! return unless lease_expiration_date lease_state = active? ? "active" : "expired" lease_record = (lease_state, Date.today, lease_expiration_date, visibility_during_lease, visibility_after_lease) self.lease_expiration_date = nil self.visibility_during_lease = nil self.visibility_after_lease = nil self.lease_history += [lease_record] end |
#lease_expiration_date=(date) ⇒ Object
8 9 10 11 |
# File 'app/models/hydra/access_controls/lease.rb', line 8 def lease_expiration_date=(date) date = DateTime.parse(date) if date.kind_of?(String) super(date) end |
#to_hash ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/hydra/access_controls/lease.rb', line 27 def to_hash {}.tap do |doc| date_field_name = Hydra.config..lease.expiration_date.sub(/_dtsi/, '') ActiveFedora::Indexing::Inserter.insert_field(doc, date_field_name, lease_expiration_date, :stored_sortable) doc[ActiveFedora.index_field_mapper.solr_name("visibility_during_lease", :symbol)] = visibility_during_lease unless visibility_during_lease.nil? doc[ActiveFedora.index_field_mapper.solr_name("visibility_after_lease", :symbol)] = visibility_after_lease unless visibility_after_lease.nil? doc[ActiveFedora.index_field_mapper.solr_name("lease_history", :symbol)] = lease_history unless lease_history.nil? end end |