/usr/lib/ruby/vendor_ruby/retryable/configuration.rb is in ruby-retryable 2.0.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | module Retryable
# Used to set up and modify settings for the retryable.
class Configuration
OPTIONS = [
:ensure,
:exception_cb,
:matching,
:on,
:sleep,
:tries,
:not,
:sleep_method
].freeze
attr_accessor :ensure
attr_accessor :exception_cb
attr_accessor :matching
attr_accessor :on
attr_accessor :sleep
attr_accessor :tries
attr_accessor :not
attr_accessor :sleep_method
attr_accessor :enabled
alias_method :enabled?, :enabled
def initialize
@ensure = Proc.new {}
@exception_cb = Proc.new {}
@matching = /.*/
@on = StandardError
@sleep = 1
@tries = 2
@not = []
@sleep_method = lambda do |seconds| Kernel.sleep(seconds) end
@enabled = true
end
def enable
@enabled = true
end
def disable
@enabled = false
end
# Allows config options to be read like a hash
#
# @param [Symbol] option Key for a given attribute
def [](option)
send(option)
end
# Returns a hash of all configurable options
def to_hash
OPTIONS.inject({}) do |hash, option|
hash[option.to_sym] = self.send(option)
hash
end
end
# Returns a hash of all configurable options merged with +hash+
#
# @param [Hash] hash A set of configuration options that will take precedence over the defaults
def merge(hash)
to_hash.merge(hash)
end
end
end
|