Class: DeleteCommand
- Inherits:
-
Object
- Object
- DeleteCommand
- Defined in:
- lib/brine/cleaner_upper.rb
Overview
A command object for the delete which will be executed as part of cleaning up.
Instance Method Summary collapse
-
#cleanup ⇒ Object
Issue the delete based on the parameters provided during construction.
-
#initialize(client, path, oks: [200,204], attempts: 3) ⇒ DeleteCommand
constructor
Construct a command with the required paramters to perform the delete.
Constructor Details
#initialize(client, path, oks: [200,204], attempts: 3) ⇒ DeleteCommand
Construct a command with the required paramters to perform the delete.
retrying if an unsuccessful status code is received.
24 25 26 27 28 29 |
# File 'lib/brine/cleaner_upper.rb', line 24 def initialize(client, path, oks: [200,204], attempts: 3) @client = client @path = path @oks = oks @attempts = attempts end |
Instance Method Details
#cleanup ⇒ Object
Issue the delete based on the parameters provided during construction.
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/brine/cleaner_upper.rb', line 35 def cleanup while @attempts > 0 begin resp=@client.delete(@path) return true if @oks.include?(resp.status) rescue ex puts "WARNING: #{ex}" end @attempts -= 1 end puts "ERROR: Could not DELETE #{@path}" false end |