Class: Textus::Store::Jobs::Retention::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/store/jobs/retention/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(container:, call:) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/textus/store/jobs/retention/base.rb', line 8

def initialize(container:, call:)
  @container = container
  @call = call
end

Instance Method Details

#call(rows) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/textus/store/jobs/retention/base.rb', line 13

def call(rows)
  out = { dropped: [], archived: [], failed: [] }
  rows.each do |row|
    key = row["key"]
    begin
      case row["action"]
      when "drop"
        delete(key)
        out[:dropped] << key
      when "archive"
        archive_leaf(row)
        delete(key)
        out[:archived] << key
      end
    rescue Textus::Error => e
      out[:failed] << { "key" => key, "error" => e.message }
    end
  end
  out
end