Class: Rumx::Beans::TimerAndError
- Inherits:
-
Timer
- Object
- Timer
- Rumx::Beans::TimerAndError
show all
- Defined in:
- lib/rumx/beans/timer_and_error.rb
Instance Method Summary
collapse
Methods inherited from Timer
#avg_time, #min_time
Methods included from Rumx::Bean
#bean_add_child, #bean_children, #bean_each, #bean_each_child, #bean_each_child_recursive, #bean_each_embedded_child, #bean_each_operation, #bean_each_operation_recursive, #bean_embedded, #bean_find, #bean_get_and_set_attributes, #bean_get_attributes, #bean_has_attributes?, #bean_has_operations?, #bean_monitor, #bean_remove_child, #bean_set_and_get_attributes, #bean_set_attributes, #bean_synchronize, find, find_attribute, find_operation, included, root
Constructor Details
Returns a new instance of TimerAndError.
8
9
10
11
12
|
# File 'lib/rumx/beans/timer_and_error.rb', line 8
def initialize(opts={})
super
@errors = []
@max_errors = (opts[:max_errors] || 1).to_i
end
|
Instance Method Details
#measure ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rumx/beans/timer_and_error.rb', line 21
def measure
super
rescue Exception => e
bean_synchronize do
@error_count += 1
@errors << Message.new(e.message)
@errors.shift while @errors.size > @max_errors
end
raise
end
|
#reset=(val) ⇒ Object
14
15
16
17
18
19
|
# File 'lib/rumx/beans/timer_and_error.rb', line 14
def reset=(val)
super
if val
@error_count = 0
end
end
|
#to_s ⇒ Object
32
33
34
|
# File 'lib/rumx/beans/timer_and_error.rb', line 32
def to_s
"error_count=#{@error_count}" + super
end
|