Class: Tally::Sweeper
- Inherits:
-
Object
- Object
- Tally::Sweeper
- Defined in:
- lib/tally/sweeper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key: nil, day: "*", record: nil, type: nil) ⇒ Sweeper
constructor
A new instance of Sweeper.
- #purge_date ⇒ Object
- #purgeable_keys ⇒ Object
- #sweep! ⇒ Object
Constructor Details
#initialize(key: nil, day: "*", record: nil, type: nil) ⇒ Sweeper
Returns a new instance of Sweeper.
4 5 6 7 8 9 |
# File 'lib/tally/sweeper.rb', line 4 def initialize(key: nil, day: "*", record: nil, type: nil) @key = key @day = day @record = record @type = type end |
Class Method Details
.sweep!(**args) ⇒ Object
35 36 37 |
# File 'lib/tally/sweeper.rb', line 35 def self.sweep!(**args) new(**args).sweep! end |
Instance Method Details
#purge_date ⇒ Object
11 12 13 |
# File 'lib/tally/sweeper.rb', line 11 def purge_date @purge_date ||= 3.days.ago.beginning_of_day.to_date end |
#purgeable_keys ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/tally/sweeper.rb', line 15 def purgeable_keys @purgeable_keys ||= finder.entries.map do |entry| if entry.date <= purge_date entry.raw_key end end.compact end |