Class: AllMyCircuits::NullBreaker
- Inherits:
-
Object
- Object
- AllMyCircuits::NullBreaker
- Defined in:
- lib/all_my_circuits/null_breaker.rb
Overview
Public: no-op circuit breaker implementation, useful for testing
Instance Attribute Summary collapse
-
#closed ⇒ Object
Returns the value of attribute closed.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name:, closed:) ⇒ NullBreaker
constructor
A new instance of NullBreaker.
- #run ⇒ Object
Constructor Details
#initialize(name:, closed:) ⇒ NullBreaker
Returns a new instance of NullBreaker.
9 10 11 12 |
# File 'lib/all_my_circuits/null_breaker.rb', line 9 def initialize(name:, closed:) @name = name @closed = closed end |
Instance Attribute Details
#closed ⇒ Object
Returns the value of attribute closed.
7 8 9 |
# File 'lib/all_my_circuits/null_breaker.rb', line 7 def closed @closed end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/all_my_circuits/null_breaker.rb', line 6 def name @name end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/all_my_circuits/null_breaker.rb', line 14 def run if @closed yield else raise AllMyCircuits::BreakerOpen, @name end end |