Confusion with dry-initializer ("Container Version")

Hello!

I have trouble understanding the motivation behind using the container version of dry-initializer. Quoting the docs:

Instead of extending a class with the Dry::Initializer, you can include a container with the initializer method only. This method should be preferred when you don’t need subclassing.

It’s not clear to me why it is the preferred method. Is it because the container version doesn’t pollute the class with the DSL methods and instance variables? Or is there another reason like performance considerations?

@smaximov as far as I know, there are some code-loading performance penalties because using the block syntax allows generating code only once. In the run-time there should be no difference.

1 Like