Class: Solid::Result::EventLogs::Tracking::Enabled
- Inherits:
-
Object
- Object
- Solid::Result::EventLogs::Tracking::Enabled
- Defined in:
- lib/solid/result/event_logs/tracking/enabled.rb
Instance Method Summary collapse
- #err!(exception, event_log_node) ⇒ Object
- #exec(name, desc) ⇒ Object
- #record(result) ⇒ Object
- #record_and_then(type_arg, arg) ⇒ Object
- #reset! ⇒ Object
- #reset_and_then! ⇒ Object
Instance Method Details
#err!(exception, event_log_node) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/solid/result/event_logs/tracking/enabled.rb', line 27 def err!(exception, event_log_node) if event_log_node.root? listener.before_interruption(exception: exception, event_logs: map_event_logs) reset! end raise exception end |
#exec(name, desc) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/solid/result/event_logs/tracking/enabled.rb', line 9 def exec(name, desc) event_log_node, scope = start(name, desc) result = nil listener.around_event_logs(scope: scope) do result = EnsureResult[yield] end tree.move_to_root! if event_log_node.root? finish(result) result rescue ::Exception => e err!(e, event_log_node) end |
#record(result) ⇒ Object
41 42 43 44 45 |
# File 'lib/solid/result/event_logs/tracking/enabled.rb', line 41 def record(result) return if tree.frozen? track(result, time: ::Time.now.getutc) end |
#record_and_then(type_arg, arg) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/solid/result/event_logs/tracking/enabled.rb', line 47 def record_and_then(type_arg, arg) return yield if tree.frozen? type = type_arg.instance_of?(::Method) ? :method : type_arg current_and_then = { type: type, arg: arg } current_and_then[:method_name] = type_arg.name if type == :method tree.current.value[1] = current_and_then scope, and_then = tree.current_value result = nil listener.around_and_then(scope: scope, and_then: and_then) { result = yield } result end |
#reset! ⇒ Object
37 38 39 |
# File 'lib/solid/result/event_logs/tracking/enabled.rb', line 37 def reset! self.tree = Tracking::EMPTY_TREE end |
#reset_and_then! ⇒ Object
66 67 68 69 70 |
# File 'lib/solid/result/event_logs/tracking/enabled.rb', line 66 def reset_and_then! return if tree.frozen? tree.current.value[1] = Tracking::EMPTY_HASH end |