class Expire::FromNowKeepMostRecentForRule
Keep the most recent backups from now for a certain period of time.
Constants
- RULE_RANK
Attributes
unit[R]
Public Class Methods
new(unit:, **args)
click to toggle source
Calls superclass method
# File lib/expire/from_now_keep_most_recent_for_rule.rb, line 16 def initialize(unit:, **args) super(**args) @unit = unit end
rank()
click to toggle source
# File lib/expire/from_now_keep_most_recent_for_rule.rb, line 12 def self.rank RULE_RANK end
Public Instance Methods
apply(backups, datetime_now)
click to toggle source
# File lib/expire/from_now_keep_most_recent_for_rule.rb, line 24 def apply(backups, datetime_now) reference_datetime = datetime_now - amount.send(unit) kept = backups.not_older_than(reference_datetime) kept.each do |backup| backup.add_reason_to_keep(reason_to_keep) end end
rank()
click to toggle source
# File lib/expire/from_now_keep_most_recent_for_rule.rb, line 33 def rank self.class.rank end
reason_to_keep()
click to toggle source
# File lib/expire/from_now_keep_most_recent_for_rule.rb, line 37 def reason_to_keep "from now keep most recent backups for #{amount} #{numerus_unit}" end