Class: OrientdbClient::Instrumenters::Memory
- Inherits:
-
Object
- Object
- OrientdbClient::Instrumenters::Memory
- Defined in:
- lib/orientdb_client/instrumenters/memory.rb
Overview
Instrumentor that is useful for tests as it stores each of the events that are instrumented.
Defined Under Namespace
Classes: Event
Instance Attribute Summary collapse
-
#events ⇒ Object
readonly
Returns the value of attribute events.
Instance Method Summary collapse
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
- #instrument(name, payload = {}) ⇒ Object
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
10 11 12 |
# File 'lib/orientdb_client/instrumenters/memory.rb', line 10 def initialize @events = [] end |
Instance Attribute Details
#events ⇒ Object (readonly)
Returns the value of attribute events.
8 9 10 |
# File 'lib/orientdb_client/instrumenters/memory.rb', line 8 def events @events end |
Instance Method Details
#instrument(name, payload = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/orientdb_client/instrumenters/memory.rb', line 14 def instrument(name, payload = {}) result = nil begin result = yield payload rescue Exception => e payload[:exception] = [e.class.name, e.] raise e ensure @events << Event.new(name, payload, result) result end end |