Module: Sandthorn

Defined in:
lib/sandthorn.rb,
lib/sandthorn/errors.rb,
lib/sandthorn/version.rb,
lib/sandthorn/event_inspector.rb,
lib/sandthorn/aggregate_root_base.rb,
lib/sandthorn/aggregate_root_snapshot.rb,
lib/sandthorn/aggregate_root_dirty_hashy.rb

Defined Under Namespace

Modules: AggregateRoot, AggregateRootSnapshot, Errors, EventInspector

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.configurationObject



11
12
13
# File 'lib/sandthorn.rb', line 11

def configuration
  @configuration ||= []
end

.configuration=(configuration) ⇒ Object



8
9
10
# File 'lib/sandthorn.rb', line 8

def configuration= configuration
  @configuration = configuration
end

.deserialize(data) ⇒ Object



22
23
24
25
26
27
# File 'lib/sandthorn.rb', line 22

def deserialize data
  #Marshal.load(data)
  YAML::load(data)
  #Oj.load(data)
  #MessagePack.unpack(data, symbolize_keys: true)
end

.generate_aggregate_idObject



29
30
31
# File 'lib/sandthorn.rb', line 29

def generate_aggregate_id
  SecureRandom.uuid
end

.get_aggregate(aggregate_id, class_name) ⇒ Object



45
46
47
# File 'lib/sandthorn.rb', line 45

def get_aggregate aggregate_id, class_name
  driver_for(class_name).get_aggregate aggregate_id, class_name
end

.get_aggregate_events(aggregate_id, class_name) ⇒ Object



33
34
35
# File 'lib/sandthorn.rb', line 33

def get_aggregate_events aggregate_id, class_name
  driver_for(class_name).get_aggregate_events aggregate_id, class_name
end

.save_events(aggregate_events, originating_aggregate_version, aggregate_id, class_name) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/sandthorn.rb', line 37

def save_events aggregate_events, originating_aggregate_version, aggregate_id, class_name
  #begin
  driver_for(class_name).save_events aggregate_events, originating_aggregate_version, aggregate_id, *class_name
  #rescue UpptecEventSequelDriver::Errors::WrongAggregateVersionError => sequel_error
  #  raise UpptecEventFramework::Errors::ConcurrencyError.new sequel_error.message
  #end
end

.save_snapshot(aggregate_snapshot, aggregate_id, class_name) ⇒ Object



49
50
51
# File 'lib/sandthorn.rb', line 49

def save_snapshot aggregate_snapshot, aggregate_id, class_name
  driver_for(class_name).save_snapshot aggregate_snapshot, aggregate_id, class_name
end

.serialize(data) ⇒ Object



15
16
17
18
19
20
# File 'lib/sandthorn.rb', line 15

def serialize data
  #Marshal.dump(data)
  YAML::dump(data)
  #Oj.dump(data)
  #MessagePack.pack(data, symbolize_keys: true)
end