lib/aws-sdk-resources/services/s3/bucket.rb in aws-sdk-resources-2.2.1 vs lib/aws-sdk-resources/services/s3/bucket.rb in aws-sdk-resources-2.2.2

- old
+ new

@@ -20,31 +20,36 @@ # # @example # # bucket.delete! # - # @option options [Float] :initial_wait (1.3) Initial wait time. Exponentially increased for each attempt. - # [Fixnum] :max_attempts (3) Maximum number of attempts to make before raising Errors::BucketNotEmpty. + # @option options [Integer] :max_attempts (3) Maximum number of times to + # attempt to delete the empty bucket before raising + # `Aws::S3::Errors::BucketNotEmpty`. # + # @option options [Float] :initial_wait (1.3) Seconds to wait before + # retrying the call to delete the bucket, exponentially increased for + # each attempt. + # # @return [void] - DELETE_BANG_DEFAULTS = { initial_wait: 1.3, max_attempts: 3 } - def delete! options = { } - options = DELETE_BANG_DEFAULTS.merge options + options = { + initial_wait: 1.3, + max_attempts: 3, + }.merge(options) attempts = 0 - begin clear! delete - rescue Errors::BucketNotEmpty => e + rescue Errors::BucketNotEmpty => error attempts += 1 - - raise e if attempts >= options[:max_attempts] - - Kernel.sleep options[:initial_wait] ** attempts - - retry + if attempts >= options[:max_attempts] + raise + else + Kernel.sleep(options[:initial_wait] ** attempts) + retry + end end end # Returns a public URL for this bucket. #