Sha256: 2b1a06661c13e5de8817e2b2ad30223dcc4c26c69d4444fe3ef541b9091c43ca

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module SandthornDriverEventStore
  class EventStore

    attr_reader :driver

    def initialize event_store_driver:
      @driver = event_store_driver
      driver.execute do |db|
        @storage = db
      end
    end

    def save_events events, aggregate_id, aggregate_type
      driver.execute do |db|
        event_access = get_event_access(db)
        events = events.map { |event| event[:aggregate_type] = aggregate_type; event[:aggregate_id] = aggregate_id; event;}
        event_access.store_events(events)
      end
    end

    def find aggregate_id, aggregate_type, after_aggregate_version = 0
      driver.execute do |db|
        event_access = get_event_access(db)
        event_access.find_events(aggregate_id, aggregate_type, after_aggregate_version)
      end
    end

    def all aggregate_type
      raise :NotImplemented
    end

    def get_events(*args)
      raise :NotImplemented
    end


    private

    def get_event_access(db)
      EventAccess.new(storage(db))
    end

    def storage(db)
      @storage
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sandthorn_driver_event_store-0.1.0 lib/sandthorn_driver_event_store/event_store.rb