class RetriableProxy::Wrapper
Public Class Methods
new(with_object, options_for_retriable = {})
click to toggle source
Creates a new Wrapper
that will wrap the messages to the wrapped object with a retriable
block.
If the :methods option is passed, only the methods in the given array will be subjected to retries.
# File lib/retriable_proxy.rb, line 12 def initialize(with_object, options_for_retriable = {}) @o = with_object @methods = options_for_retriable.delete(:methods) @retriable_options = options_for_retriable end
Public Instance Methods
__getobj__()
click to toggle source
Returns the wrapped object
# File lib/retriable_proxy.rb, line 19 def __getobj__ @o end
method_missing(*a) { |*ba| ... }
click to toggle source
Forwards all methods not defined on the Wrapper
to the wrapped object.
# File lib/retriable_proxy.rb, line 29 def method_missing(*a) method_name = a[0] if block_given? __retrying(method_name) { @o.public_send(*a){|*ba| yield(*ba)} } else __retrying(method_name) { @o.public_send(*a) } end end
respond_to_missing?(*a)
click to toggle source
Assists in supporting method_missing
# File lib/retriable_proxy.rb, line 24 def respond_to_missing?(*a) @o.respond_to?(*a) end
Private Instance Methods
__retrying(method_name_on_delegate) { || ... }
click to toggle source
Executes a block within Retriable setup with @retriable_options
# File lib/retriable_proxy.rb, line 41 def __retrying(method_name_on_delegate) if @methods.nil? || @methods.include?(method_name_on_delegate) Retriable.retriable(@retriable_options) { yield } else yield end end