Sha256: 1d99b4e9954d309e9cbbb8ad36faa60ac40049fcbfcb6d0353d2bb8b9f708572

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

module OwskiLog
  module EventManager
    def register_event(event_collection, event, parent_key: nil)
      raise ArgumentError.new('You can only register owskilog::Event.') unless event.is_a? Event

      if parent_key != nil
        event.parent = find_event(event_collection,parent_key)
      end

      event_collection[event.key] = event
    end

    def find_event(event_collection, event_key)
      event_collection[event_key]
    end

    def finish_event(event_collection, event_key, status, cause: nil)
      ev = find_event(event_collection, event_key)
      if ev
        ev.finish(status, cause: cause)
        if ev.parent != nil && cause != nil
          ev.parent.finish(status, cause: cause)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
owskilog-0.2.0 lib/owskilog/event_manager.rb