Class: CircuitSwitch::Builder
- Inherits:
-
Core
- Object
- Core
- CircuitSwitch::Builder
show all
- Defined in:
- lib/circuit_switch/builder.rb
Instance Attribute Summary
Attributes inherited from Core
#close_if, #close_if_reach_limit, #initially_closed, #key, #report_if, #report_limit_count, #run_if, #run_limit_count, #stop_report_if, #stop_report_if_reach_limit
Instance Method Summary
collapse
-
#assign_reporter(key: nil, if: true, stop_report_if: false, stop_report_if_reach_limit: true, limit_count: nil) ⇒ Object
-
#assign_runner(key: nil, if: true, close_if: false, close_if_reach_limit: false, limit_count: nil, initially_closed: false) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
-
#report(key: nil, if: nil, stop_report_if: nil, stop_report_if_reach_limit: nil, limit_count: nil) ⇒ Object
-
#run(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil, &block) ⇒ Object
Methods inherited from Core
#execute_report, #execute_run, #reported?, #run?
Constructor Details
Returns a new instance of Builder.
5
6
7
8
9
|
# File 'lib/circuit_switch/builder.rb', line 5
def initialize
super
@run = false
@reported = false
end
|
Instance Method Details
#assign_reporter(key: nil, if: true, stop_report_if: false, stop_report_if_reach_limit: true, limit_count: nil) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/circuit_switch/builder.rb', line 27
def assign_reporter(
key: nil,
if: true,
stop_report_if: false,
stop_report_if_reach_limit: true,
limit_count: nil
)
@key = key
@report_if = binding.local_variable_get(:if)
@stop_report_if = stop_report_if
@stop_report_if_reach_limit = stop_report_if_reach_limit
@report_limit_count = limit_count
end
|
#assign_runner(key: nil, if: true, close_if: false, close_if_reach_limit: false, limit_count: nil, initially_closed: false) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/circuit_switch/builder.rb', line 11
def assign_runner(
key: nil,
if: true,
close_if: false,
close_if_reach_limit: false,
limit_count: nil,
initially_closed: false
)
@key = key
@run_if = binding.local_variable_get(:if)
@close_if = close_if
@close_if_reach_limit = close_if_reach_limit
@run_limit_count = limit_count
@initially_closed = initially_closed
end
|
#report(key: nil, if: nil, stop_report_if: nil, stop_report_if_reach_limit: nil, limit_count: nil) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/circuit_switch/builder.rb', line 54
def report(key: nil, if: nil, stop_report_if: nil, stop_report_if_reach_limit: nil, limit_count: nil)
arguments = {
key: key,
if: binding.local_variable_get(:if),
stop_report_if: stop_report_if,
stop_report_if_reach_limit: stop_report_if_reach_limit,
limit_count: limit_count
}.reject { |_, v| v.nil? }
assign_reporter(**arguments)
execute_report
end
|
#run(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil, &block) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/circuit_switch/builder.rb', line 41
def run(key: nil, if: nil, close_if: nil, close_if_reach_limit: nil, limit_count: nil, initially_closed: nil, &block)
arguments = {
key: key,
if: binding.local_variable_get(:if),
close_if: close_if,
close_if_reach_limit: close_if_reach_limit,
limit_count: limit_count,
initially_closed: initially_closed,
}.reject { |_, v| v.nil? }
assign_runner(**arguments)
execute_run(&block)
end
|