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.
- .sanitize_text(value) ⇒ Object
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.)
31 32 33 34 |
# File 'app/models/angarium/delivery_attempt.rb', line 31 def self.prune(older_than:) cutoff = older_than.is_a?(ActiveSupport::Duration) ? older_than.ago : older_than where(created_at: ...cutoff).delete_all end |
.sanitize_text(value) ⇒ Object
23 24 25 |
# File 'app/models/angarium/delivery_attempt.rb', line 23 def self.sanitize_text(value) value.dup.force_encoding(Encoding::UTF_8).scrub.delete("\u0000") end |