Sha256: 1015534e151cc555379753f118f6caec9584ce5c99bcdc820f10b08aca5dcfda

Contents?: true

Size: 886 Bytes

Versions: 2

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

require 'roko/source/configurable'

module Roko
  module Source
    # base module for event sources
    module Base
      # report event
      class ReportEvents
        include Roko::Source::Configurable

        def initialize(configurable = nil)
          configure_with(configurable) unless configurable.nil?
        end

        def fetch
          fetch_service_event(client)
            .map! { |event| to_report_event(event) }
            .compact
            .filter { |e| e.created_at.between?(@start, @end) }
            .sort_by(&:created_at)
        end

        private

        def client
          raise NotImplementedError
        end

        def fetch_service_event(_client)
          raise NotImplementedError
        end

        def to_report_event(_event)
          raise NotImplementedError
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roko-0.2.1 lib/roko/source/base/report_events.rb
roko-0.2.0 lib/roko/source/base/report_events.rb