Module: AggregateRoot

Defined in:
lib/aggregate_root.rb,
lib/aggregate_root/version.rb,
lib/aggregate_root/repository.rb,
lib/aggregate_root/snapshot_repository.rb,
lib/aggregate_root/default_apply_strategy.rb,
lib/aggregate_root/instrumented_repository.rb,
lib/aggregate_root/instrumented_apply_strategy.rb

Defined Under Namespace

Modules: AggregateMethods, Constructor, OnDSL Classes: DefaultApplyStrategy, InstrumentedApplyStrategy, InstrumentedRepository, Repository, SnapshotRepository

Constant Summary collapse

VERSION =
"3.0.0"
MissingHandler =
Class.new(StandardError)
NullHandler =
Proc.new {}

Class Method Summary collapse

Class Method Details

.included(host_class) ⇒ Object



95
96
97
98
# File 'lib/aggregate_root.rb', line 95

def self.included(host_class)
  host_class.extend OnDSL
  host_class.include with
end

.with(strategy: -> { DefaultApplyStrategy.new }, event_type_resolver: ->(value) { value.to_s }) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/aggregate_root.rb', line 79

def self.with(strategy: -> { DefaultApplyStrategy.new }, event_type_resolver: ->(value) { value.to_s })
  Module.new do
    define_singleton_method :included do |host_class|
      host_class.extend Constructor
      host_class.include AggregateMethods
      host_class.define_singleton_method :event_type_for do |value|
        event_type_resolver.call(value)
      end
    end

    define_method :apply_strategy do
      strategy.call
    end
  end
end