Class: RetriableProxy::Wrapper
- Inherits:
-
Object
- Object
- RetriableProxy::Wrapper
- Defined in:
- lib/retriable_proxy.rb
Instance Method Summary collapse
-
#__getobj__ ⇒ Object
Returns the wrapped object.
-
#initialize(with_object, options_for_retriable = {}) ⇒ Wrapper
constructor
Creates a new Wrapper that will wrap the messages to the wrapped object with a
retriable
block. -
#method_missing(*a) ⇒ Object
Forwards all methods not defined on the Wrapper to the wrapped object.
-
#respond_to_missing?(*a) ⇒ Boolean
Assists in supporting method_missing.
Constructor Details
#initialize(with_object, options_for_retriable = {}) ⇒ Wrapper
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.
12 13 14 15 16 |
# File 'lib/retriable_proxy.rb', line 12 def initialize(with_object, = {}) @o = with_object @methods = .delete(:methods) @retriable_options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*a) ⇒ Object
Forwards all methods not defined on the Wrapper to the wrapped object.
29 30 31 32 33 34 35 36 |
# File 'lib/retriable_proxy.rb', line 29 def method_missing(*a) method_name = a[0] if block_given? (method_name) { @o.public_send(*a){|*ba| yield(*ba)} } else (method_name) { @o.public_send(*a) } end end |
Instance Method Details
#__getobj__ ⇒ Object
Returns the wrapped object
19 20 21 |
# File 'lib/retriable_proxy.rb', line 19 def __getobj__ @o end |
#respond_to_missing?(*a) ⇒ Boolean
Assists in supporting method_missing
24 25 26 |
# File 'lib/retriable_proxy.rb', line 24 def respond_to_missing?(*a) @o.respond_to?(*a) end |