These are chat archives for dry-rb/chat

22nd
May 2017
Stergio
@stergiom
May 22 2017 16:35
class AutoMe
  include Inject[:some_thing]

  def initialize(*)
    # stuff..

   some_thing.do   #NoMethodError: undefined method `do' for nil:NilClass
  end
end
Should dry-auto_inject work defined this way?
Andy Holland
@AMHOL
May 22 2017 16:36
@stergiom, I think you need to call super first
Stergio
@stergiom
May 22 2017 16:39
that works, :beers: Andy
Stergio
@stergiom
May 22 2017 16:46
is a super needed for all cases where an initialize is defined and dry-auto_inject is used?
Andy Holland
@AMHOL
May 22 2017 17:03
Yeah it will be
All of the instance variables for the dependencies are set in #initialize, so they won't be available in a custom initializer until after you call super
@stergiom it would probably be good form to use the method footprint initialize(*, **, &b) too, as you can inject keyword arguments, and the above will break if that happens