Class: Expire::KeepMostRecentForRule

Inherits:
FromNowKeepMostRecentForRule show all
Extended by:
FromRangeValue
Includes:
NumerusUnit
Defined in:
lib/expire/keep_most_recent_for_rule.rb

Overview

Keep the most recent backups for a certain period of time.

Constant Summary collapse

RULE_RANK =
11

Constants included from FromRangeValue

FromRangeValue::FROM_VALUE_REGEX

Instance Attribute Summary collapse

Attributes inherited from RuleBase

#amount

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FromRangeValue

from_value

Methods included from NumerusUnit

#numerus_unit

Methods inherited from FromNowKeepMostRecentForRule

#initialize

Methods inherited from RuleBase

<=>, #<=>, camelized_name, #initialize, name, #name, #numerus_backup, #option_name, option_name

Constructor Details

This class inherits a constructor from Expire::FromNowKeepMostRecentForRule

Instance Attribute Details

#unitObject (readonly)

Returns the value of attribute unit.



12
13
14
# File 'lib/expire/keep_most_recent_for_rule.rb', line 12

def unit
  @unit
end

Class Method Details

.rankObject



14
15
16
# File 'lib/expire/keep_most_recent_for_rule.rb', line 14

def self.rank
  RULE_RANK
end

Instance Method Details

#apply(backups, _) ⇒ Object



18
19
20
21
# File 'lib/expire/keep_most_recent_for_rule.rb', line 18

def apply(backups, _)
  reference_time = backups.newest
  super(backups, reference_time)
end

#rankObject



23
24
25
# File 'lib/expire/keep_most_recent_for_rule.rb', line 23

def rank
  self.class.rank
end

#reason_to_keepObject



27
28
29
# File 'lib/expire/keep_most_recent_for_rule.rb', line 27

def reason_to_keep
  "keep most recent backups for #{amount} #{numerus_unit}"
end