Skip to content

Commit d9b5e63

Browse files
lukaszreszkemostlyobviousfidel
committed
Always include OnDSL in DefaultApplyStrategy
DefaultApplyStrategy relies on OnDSL. Therefore they always have to go together. https: //github.com//issues/982 Co-authored-by: Paweł Pacana <[email protected]> Co-authored-by: Szymon Fiedler <[email protected]>
1 parent 4285975 commit d9b5e63

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

aggregate_root/lib/aggregate_root.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ def marshal_load(vars)
7676
end
7777
end
7878

79-
def self.with_default_apply_strategy
79+
def self.with_default_apply_strategy(strict: true)
8080
Module.new do
8181
def self.included(host_class)
82-
host_class.include AggregateRoot.with_strategy(-> { DefaultApplyStrategy.new })
82+
host_class.extend OnDSL
83+
host_class.extend Constructor
84+
host_class.include AggregateMethods
85+
end
86+
87+
define_method :apply_strategy do
88+
DefaultApplyStrategy.new(strict: strict)
8389
end
8490
end
8591
end

aggregate_root/spec/aggregate_root_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def expire
6868

6969
it "should ignore missing apply method based on a default non-strict apply strategy" do
7070
klass =
71-
Class.new { include AggregateRoot.with_strategy(-> { AggregateRoot::DefaultApplyStrategy.new(strict: false) }) }
71+
Class.new { include AggregateRoot.with_default_apply_strategy(strict: false) }
7272
order = klass.new
7373
spanish_inquisition = Orders::Events::SpanishInquisition.new
7474
expect { order.apply(spanish_inquisition) }.to_not raise_error

0 commit comments

Comments
 (0)