app/models/concerns/hydra/access_controls/embargoable.rb in hydra-access-controls-9.2.2 vs app/models/concerns/hydra/access_controls/embargoable.rb in hydra-access-controls-9.3.0

- old
+ new

@@ -33,15 +33,23 @@ lease || build_lease end def to_solr(solr_doc = {}) super.tap do |doc| - doc.merge!(embargo.to_hash) if embargo - doc.merge!(lease.to_hash) if lease + doc.merge!(embargo_indexer_class.new(embargo).generate_solr_document) if embargo + doc.merge!(lease_indexer_class.new(lease).generate_solr_document) if lease end end + def embargo_indexer_class + EmbargoIndexer + end + + def lease_indexer_class + LeaseIndexer + end + def under_embargo? embargo && embargo.active? end def active_lease? @@ -61,11 +69,11 @@ def apply_embargo(release_date, visibility_during=nil, visibility_after=nil) self.embargo_release_date = release_date self.visibility_during_embargo = visibility_during unless visibility_during.nil? self.visibility_after_embargo = visibility_after unless visibility_after.nil? embargo_visibility! - visibility_will_change! + visibility_will_change! if embargo.changed? end def deactivate_embargo! embargo && embargo.deactivate! visibility_will_change! @@ -132,10 +140,10 @@ def apply_lease(release_date, visibility_during=nil, visibility_after=nil) self.lease_expiration_date = release_date self.visibility_during_lease = visibility_during unless visibility_during.nil? self.visibility_after_lease = visibility_after unless visibility_after.nil? lease_visibility! - visibility_will_change! + visibility_will_change! if lease.changed? end def deactivate_lease! lease && lease.deactivate! visibility_will_change!