Module: CircuitBreaker::ClassMethods
- Defined in:
- lib/circuit_breaker.rb
Instance Method Summary collapse
-
#circuit_handler {|@circuit_handler| ... } ⇒ Object
Returns circuit_handler.
-
#circuit_handler_class(klass = nil) ⇒ Object
Allows you to define a custom circuit_handler instead of CircuitBreaker::CircuitHandler.
-
#circuit_method(*methods) ⇒ Object
Takes a splat of method names, and wraps them with the circuit_handler.
Instance Method Details
#circuit_handler {|@circuit_handler| ... } ⇒ Object
Returns circuit_handler. Yields the instance back when passed a block.
89 90 91 92 93 94 95 |
# File 'lib/circuit_breaker.rb', line 89 def circuit_handler(&block) @circuit_handler ||= circuit_handler_class.new yield @circuit_handler if block_given? return @circuit_handler end |
#circuit_handler_class(klass = nil) ⇒ Object
Allows you to define a custom circuit_handler instead of CircuitBreaker::CircuitHandler
100 101 102 |
# File 'lib/circuit_breaker.rb', line 100 def circuit_handler_class(klass = nil) @circuit_handler_class ||= (klass || CircuitBreaker::CircuitHandler) end |
#circuit_method(*methods) ⇒ Object
Takes a splat of method names, and wraps them with the circuit_handler.
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/circuit_breaker.rb', line 75 def circuit_method(*methods) circuit_handler = self.circuit_handler methods.each do |meth| m = instance_method meth define_method meth do |*args| circuit_handler.handle self.circuit_state, m.bind(self), *args end end end |