Class: Angarium::DeliveryAttempt
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Angarium::DeliveryAttempt
- Defined in:
- app/models/angarium/delivery_attempt.rb
Class Method Summary collapse
-
.prune(older_than:) ⇒ Object
Delete delivery attempts older than the cutoff.
Class Method Details
.prune(older_than:) ⇒ Object
Delete delivery attempts older than the cutoff. older_than may be a
duration (e.g. 90.days) or an absolute Time. Returns the number deleted.
(A Time also responds to #ago but requires an argument, so branch on the
type rather than duck-typing #ago.)
9 10 11 12 |
# File 'app/models/angarium/delivery_attempt.rb', line 9 def self.prune(older_than:) cutoff = older_than.is_a?(ActiveSupport::Duration) ? older_than.ago : older_than where(created_at: ...cutoff).delete_all end |