Module: Lieutenant::Aggregate

Defined in:
lib/lieutenant/aggregate.rb

Overview

Representation of an aggregate root

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



37
38
39
# File 'lib/lieutenant/aggregate.rb', line 37

def id
  @id
end

#uncommitted_eventsObject (readonly)

Returns the value of attribute uncommitted_events.



38
39
40
# File 'lib/lieutenant/aggregate.rb', line 38

def uncommitted_events
  @uncommitted_events
end

#versionObject

Returns the value of attribute version.



39
40
41
# File 'lib/lieutenant/aggregate.rb', line 39

def version
  @version
end

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/lieutenant/aggregate.rb', line 6

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#mark_as_committedObject



41
42
43
44
# File 'lib/lieutenant/aggregate.rb', line 41

def mark_as_committed
  self.version += uncommitted_events.size
  uncommitted_events.clear
end