Module: AggregateRoot

Defined in:
lib/aggregate_root.rb,
lib/aggregate_root/version.rb,
lib/aggregate_root/transform.rb,
lib/aggregate_root/deprecated.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.19.2"
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



110
111
112
113
# File 'lib/aggregate_root.rb', line 110

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



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/aggregate_root.rb', line 94

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



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

def self.with_default_apply_strategy
  Module.new do
    def self.included(host_class)
      host_class.include AggregateRoot
    end
  end
end

.with_strategy(strategy) ⇒ Object



90
91
92
# File 'lib/aggregate_root.rb', line 90

def self.with_strategy(strategy)
  with(strategy: strategy)
end