These are chat archives for dry-rb/chat

29th
Oct 2015
Piotr Solnica
@solnic
Oct 29 2015 09:01
@AMHOL this can be useful for cases where you don’t want to use auto-inject, there is a gem that does exactly that called concord but it is super opinionated and uses a limit of 3 collaborators
btw I wanted to tweak auto-inject to define a constructor with hash as arg (or k/v args maybe)
this way it’s easier to instantiate an object and pass a mock
Andy Holland
@AMHOL
Oct 29 2015 11:46
Yeah, sounds good, could use dry-dependencies to define the constructor in auto-inject too
Piotr Solnica
@solnic
Oct 29 2015 11:56
yes, that’s a good idea, I thought about this too
@AMHOL ^
Andy Holland
@AMHOL
Oct 29 2015 11:57
:)
Piotr Solnica
@solnic
Oct 29 2015 11:57
but maybe let’s call it dry-constructor or dry-initialize?
one more thing - I’d like to fork equalizer into dry-equalizer and tweak it a little bit; seems like Dan hasn’t got the time to maintain it and equalizer is heavily used by lots of projects so it’s harder to make changes in it
there’s a weird behavior in equalizer right now where it tries to do Object#coerce which was a design mistake, it goes back to the roots of this library which is axiom gem where this behavior was useful, but as a generalized interface it’s actually causing issues (and makes it slower too)
object equality is pretty fundamental in our style of coding, so I think dry-equalizer would be an awesome addition
Andy Holland
@AMHOL
Oct 29 2015 12:10
Yeah, definitely, assuming Dan is OK with that
Could go with either of those, went with dry-dependencies as it adds the dependencies macro
Piotr Solnica
@solnic
Oct 29 2015 12:30
@AMHOL I prefer module subclassing, it removes the need for defining new class methods
Andy Holland
@AMHOL
Oct 29 2015 12:32
With the dry-dependencies thing?
Piotr Solnica
@solnic
Oct 29 2015 12:38
yes
Andy Holland
@AMHOL
Oct 29 2015 12:42
So like:
class MyClass
  include Dry::Dependencies[:one, :two, :three]
end
Piotr Solnica
@solnic
Oct 29 2015 12:42
right, sth like that
Andy Holland
@AMHOL
Oct 29 2015 12:43
Cool, makes sense
I'll change that later
Initialize or Constructor then?
My one concern is that the visibility modifier will look weird with that
class MyClass
  include Dry::Dependencies[:one, :two, :three, visibility: :private]
end
Piotr Solnica
@solnic
Oct 29 2015 12:46
include Dry::Dependencies::Private[:one, :two]
Andy Holland
@AMHOL
Oct 29 2015 12:49
That could work
Andy Holland
@AMHOL
Oct 29 2015 20:57
@solnic, thinking about that interface, it won't work with inheritance
ATM I can do:
class BaseController
  include Dry::Dependencies
  dependencies :app
end
class UsersController < BaseController
  dependencies :repo, :validator #, ...
end
UsersController.new(app, repo, validator)
Andy Holland
@AMHOL
Oct 29 2015 23:14
Thinking of changing dry-validator to dry-validation and something like this: https://gist.github.com/AMHOL/fdf0a90292914ad758ec
Would be good to get some opinions though