Module: AggregateRoot

Defined in:
lib/aggregate_root.rb,
lib/aggregate_root/version.rb,
lib/aggregate_root/transform.rb,
lib/aggregate_root/repository.rb,
lib/aggregate_root/configuration.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: Configuration, DefaultApplyStrategy, InstrumentedApplyStrategy, InstrumentedRepository, Repository, SnapshotRepository, Transform

Constant Summary collapse

VERSION =
"2.17.1"
MissingHandler =
Class.new(StandardError)

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



5
6
7
# File 'lib/aggregate_root/configuration.rb', line 5

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Yields:



8
9
10
11
# File 'lib/aggregate_root/configuration.rb', line 8

def self.configure
  self.configuration ||= Configuration.new
  yield(configuration)
end

.included(host_class) ⇒ Object



115
116
117
118
# File 'lib/aggregate_root.rb', line 115

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



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/aggregate_root.rb', line 99

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

.with_default_apply_strategyObject



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

def self.with_default_apply_strategy
  Module.new do
    def self.included(host_class)
      warn <<~EOW
        Please replace include AggregateRoot.with_default_apply_strategy with include AggregateRoot
      EOW
      host_class.include AggregateRoot
    end
  end
end

.with_strategy(strategy) ⇒ Object



92
93
94
95
96
97
# File 'lib/aggregate_root.rb', line 92

def self.with_strategy(strategy)
  warn <<~EOW
    Please replace include AggregateRoot.with_strategy(...) with include AggregateRoot.with(strategy: ...)
  EOW
  with(strategy: strategy)
end