module Sandthorn

Constants

VERSION

Public Class Methods

all(aggregate_type) click to toggle source
# File lib/sandthorn.rb, line 40
def all aggregate_type
  event_store_for(aggregate_type).all(aggregate_type)
end
configuration() click to toggle source
# File lib/sandthorn.rb, line 28
def configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source
# File lib/sandthorn.rb, line 24
def configure
  yield(configuration) if block_given?
end
default_event_store() click to toggle source
# File lib/sandthorn.rb, line 16
def default_event_store
  event_stores.default_store
end
default_event_store=(store) click to toggle source
# File lib/sandthorn.rb, line 20
def default_event_store=(store)
  event_stores.default_store = store
end
find(aggregate_id, aggregate_type, after_aggregate_version = 0) click to toggle source
# File lib/sandthorn.rb, line 44
def find aggregate_id, aggregate_type, after_aggregate_version = 0
  event_store_for(aggregate_type).find(aggregate_id, aggregate_type, after_aggregate_version)
end
find_event_store(name) click to toggle source
# File lib/sandthorn.rb, line 57
def find_event_store(name)
  event_stores.by_name(name)
end
find_snapshot(aggregate_id) click to toggle source
# File lib/sandthorn.rb, line 53
def find_snapshot aggregate_id
  return snapshot_store.find aggregate_id
end
generate_aggregate_id() click to toggle source
# File lib/sandthorn.rb, line 32
def generate_aggregate_id
  SecureRandom.uuid
end
save_events(aggregate_events, aggregate_id, aggregate_type) click to toggle source
# File lib/sandthorn.rb, line 36
def save_events aggregate_events, aggregate_id, aggregate_type
  event_store_for(aggregate_type).save_events aggregate_events, aggregate_id, *aggregate_type
end
save_snapshot(aggregate) click to toggle source
# File lib/sandthorn.rb, line 48
def save_snapshot aggregate
  raise Errors::SnapshotError, "Can't take snapshot on object with unsaved events" if aggregate.unsaved_events?
  snapshot_store.save aggregate.aggregate_id, aggregate
end

Private Class Methods

event_store_for(aggregate_type) { |store| ... } click to toggle source
# File lib/sandthorn.rb, line 63
def event_store_for(aggregate_type)
  event_store = event_stores.by_name(aggregate_type.event_store).tap do |store|
    yield(store) if block_given?
  end
end
missing_key(key) click to toggle source
# File lib/sandthorn.rb, line 69
def missing_key(key)
  raise ArgumentError, "missing keyword: #{key}"
end