module EventSource::Postgres::Controls::Put

Public Class Methods

call(instances: nil, stream_name: nil, event: nil, category: nil) click to toggle source
# File lib/event_source/postgres/controls/put.rb, line 5
def self.call(instances: nil, stream_name: nil, event: nil, category: nil)
  instances ||= 1
  stream_name ||= StreamName.example(category: category)

  event_specified = !event.nil?

  event ||= EventData::Write.example

  instances.times do
    EventSource::Postgres::Put.(event, stream_name)

    unless event_specified
      event.id = EventData::Write.id
    end
  end

  stream_name
end