These are chat archives for dry-rb/chat
finalize!method. Where/When do I have to call it so that all my dependencies are availiable?
class SomeClass def initialize(arg1, arg2) @arg1 = arg1 @arg2 = arg2 end end
@choallin Typically you want to call
finalize! as part of the “boot” process for your app (i.e. something that happens just once when the application starts/boots).
For providing dependencies to your
SomeClass example, you might like to look into dry-system’s auto-injection feature: http://dry-rb.org/gems/dry-system/auto-import/
arg2INTO my dependency. Like this:
class OtherClass Injector['someclass'] # how can I pass the args to SomeClass? end
SomeClassto inject dependencies from your container there, or you can make
SomeClassa bootable dependency, alternatively, you can place it outside of your autoloading directory structure and register it manually.
MyContainer.register('some_class') do |arg_1, arg_2| SomeClass.new(arg_1, arg_2) end