Class: Textus::Background::Retention::Apply

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/background/retention/apply.rb

Instance Method Summary collapse

Constructor Details

#initialize(container:, call:) ⇒ Apply

Returns a new instance of Apply.



7
8
9
10
# File 'lib/textus/background/retention/apply.rb', line 7

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

Instance Method Details

#call(rows) ⇒ Object



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

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