Class: Rumx::Beans::TimerAndError
- Defined in:
- lib/rumx/beans/timer_and_error.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ TimerAndError
constructor
A new instance of TimerAndError.
- #measure ⇒ Object
- #to_s ⇒ Object
Methods inherited from Timer
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
#initialize(opts = {}) ⇒ TimerAndError
Returns a new instance of TimerAndError.
8 9 10 11 12 13 |
# File 'lib/rumx/beans/timer_and_error.rb', line 8 def initialize(opts={}) super @error_count = 0 @errors = [] @max_errors = (opts[:max_errors] || 1).to_i end |
Instance Method Details
#measure ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rumx/beans/timer_and_error.rb', line 15 def measure super rescue Exception => e bean_synchronize do @error_count += 1 @errors << Message.new(e.) @errors.shift while @errors.size > @max_errors end raise end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/rumx/beans/timer_and_error.rb', line 26 def to_s "error_count=#{@error_count}" + super end |