Class: Burden::Wrapper
- Inherits:
-
Object
- Object
- Burden::Wrapper
- Defined in:
- lib/burden/wrapper.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#execution_time ⇒ Object
readonly
Returns the value of attribute execution_time.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(name, block) ⇒ Wrapper
constructor
A new instance of Wrapper.
Constructor Details
#initialize(name, block) ⇒ Wrapper
Returns a new instance of Wrapper.
5 6 7 8 9 10 |
# File 'lib/burden/wrapper.rb', line 5 def initialize(name, block) @name = name @block = block @success = true @timestamp = Time.now.utc end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
3 4 5 |
# File 'lib/burden/wrapper.rb', line 3 def block @block end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
3 4 5 |
# File 'lib/burden/wrapper.rb', line 3 def exception @exception end |
#execution_time ⇒ Object (readonly)
Returns the value of attribute execution_time.
3 4 5 |
# File 'lib/burden/wrapper.rb', line 3 def execution_time @execution_time end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/burden/wrapper.rb', line 3 def name @name end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
3 4 5 |
# File 'lib/burden/wrapper.rb', line 3 def success @success end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
3 4 5 |
# File 'lib/burden/wrapper.rb', line 3 def @timestamp end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/burden/wrapper.rb', line 12 def execute return block.call if ignored? result = measure_time do intercept_exceptions do block.call end end save_statistics unless success Burden.config.trigger_failure_callback(name, execution_time, ) raise(exception) end Burden.config.trigger_success_callback(name, execution_time, ) result end |