I started using dry-auto_inject
gem with kwargs strategy, but I am not sure if I understand why super(**dependencies)
should be in initialize method when including Dry Container in my class.
https://dry-rb.org/gems/dry-auto_inject/how-does-it-work/
In example below, class MyService is child of base_service
class.
#base_service.rb
class BaseService
def self.call(*args)
new(*args).call
end
def call
raise 'Not implemented'
end
end
#my_service.rb
class MyService < BaseService
include InjectServices[ 'some_service', 'external_service' ]
def initialize(fields:, **dependencies)
@fields = fields
super(**dependencies)
end
end
Do I need super(**dependencies)
? I would be grateful if I could get a more detailed explanation.