These are chat archives for dry-rb/chat

12th
Nov 2015
Benjamin Klotz
@tak1n
Nov 12 2015 10:15
at our company I'm trying to introduce dry-constructor as injector lib for our service objects
we use initializers and specify default collaborators, but for specs u can inject mocks and unit test the service object itself
is there a way to specify default values for dependencies injected by dry-constructor?
eg :
class DoThings
  def initializer(collab = Collaborator.new)
    @collab = collab
  end
end
and in specs u can do DoThings.new(double).call
in controller or anywhere else u do DoThings.new.call
Andy Holland
@AMHOL
Nov 12 2015 10:39
@tak1n, dry-constructor is just for defining the constructor with the args to inject and assigning them to ivars, might be worth looking at Dry::AutoInject
@tak1n if you're using Rails, worth talking to @solnic as he recently implemented IoC in Rails and said it worked really well
Benjamin Klotz
@tak1n
Nov 12 2015 10:49
@AMHOL okay thx :)
Andy Holland
@AMHOL
Nov 12 2015 10:49
NP :)
Hannes Nevalainen
@kwando
Nov 12 2015 14:35
This message was deleted
nvm, it won't work for more complex cases anyway
Piotr Solnica
@solnic
Nov 12 2015 14:37
@kwando hmm?
Hannes Nevalainen
@kwando
Nov 12 2015 14:39
let(:container){ Hash.new{ |_,k| MyAppContainer.resolve(k) }
This message was deleted
then override as needed in tests
Piotr Solnica
@solnic
Nov 12 2015 14:46
@AMHOL can we push new dry-container release? I’d like to get off of master in rodakase
Andy Holland
@AMHOL
Nov 12 2015 14:47
@solnic yeah, do you have permissions on rubygems?
Piotr Solnica
@solnic
Nov 12 2015 15:07
@AMHOL I don’t think so
Piotr Solnica
@solnic
Nov 12 2015 15:15
@AMHOL can dry-configurable be used on an object instance level?
Andy Holland
@AMHOL
Nov 12 2015 15:16
No, there was a reason why I made it like that but that was a while ago now
Piotr Solnica
@solnic
Nov 12 2015 15:16
it’s ok, just curious
Andy Holland
@AMHOL
Nov 12 2015 15:17
Think I just thought configuring instances was a bad idea, should just use DI
To compose behaviour
Piotr Solnica
@solnic
Nov 12 2015 15:45
@AMHOL could you add me to dry-container on rubygems and/or release a new version?
Andy Holland
@AMHOL
Nov 12 2015 15:47
@solnic rubygems says you've got access?
Piotr Solnica
@solnic
Nov 12 2015 15:47
ah ok
Andy Holland
@AMHOL
Nov 12 2015 18:19
Need to update readme in dry-equalizer BTW
Piotr Solnica
@solnic
Nov 12 2015 18:31
@AMHOL right