Sha256: 41680df85ded11214ff547d8b7d9e61cbc169709df37b2fae804db5dae7b2b8a

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

module SandthornDriverSequel
  class Storage
    # = Storage
    # Abstracts access to contextualized database tables.
    #
    # == Rationale
    # Provide object-oriented access to the different tables to other objects.
    # Make it unnecessary for them to know about the current context.
    include EventStoreContext

    attr_reader :db

    def initialize(db, context)
      @db = db
      @context = context
    end

    # Returns a Sequel::Model for accessing aggregates
    def aggregates
      Class.new(Sequel::Model(aggregates_table))
    end

    # Returns a Sequel::Model for accessing events
    def events
      Class.new(Sequel::Model(events_table))
    end

    def aggregates_table
      db[aggregates_table_name]
    end

    def events_table
      db[events_table_name]
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sandthorn_driver_sequel-4.1.0 lib/sandthorn_driver_sequel/storage.rb
sandthorn_driver_sequel-4.0.0 lib/sandthorn_driver_sequel/storage.rb