Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `on_methods' when using AggregateRoot with custom apply strategy #678

Closed
jakubkosinski opened this issue Oct 17, 2019 · 1 comment
Labels

Comments

@jakubkosinski
Copy link
Contributor

When you use include AggregateRoot.with_strategy(strategy) you're getting

undefined method `on_methods'

when applying facts because OnDSL module is not included - it's included only when you're using default strategy (with include AggregateRoot).

It turned out that for custom strategy we're extending a module with Constructor module while with default strategy there's extend OnDSL.

@mostlyobvious
Copy link
Member

My doubt is: do we really want OnDSL for custom strategies? That is a fine default but once you diverge from default, I have a feeling you don't need that on handlers because you have your own event->method dispatch.

mostlyobvious added a commit that referenced this issue Feb 26, 2020
- default strategy extends class with OnDSL
- with custom strategy you likely don't want any of the DSLs
- custom strategy which is just DefaultApplyStrategy.new(strict: true)
  and wants `on_methods` needs following:

   class MyAggregate
     include AggregateRoot.with_strategy(->{ DefaultApplyStrategy.new(strict: false) })
     extend  AggregateRoot::OnDSL
   end

[#678, #679]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants