Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Piotr Solnica
@solnic
wdym?
Andy Holland
@AMHOL
To allow registration under keys that don't have any relation to the class name
Piotr Solnica
@solnic
yeah we can use some configurable strategies for figuring this out
Andy Holland
@AMHOL
sth like
Dry::Component.configure do |config|
  config.mapping = {
    'user_validator' => 'users.validator'
  }
end
Then when it loads UserValidator it registers under users.validator
Rather than just computing keys from the constant name
It's a bad example, but the idea is that it allows for more abstract keys
Andy Holland
@AMHOL
Or perhaps just allow for a custom component loader
Piotr Solnica
@solnic
we can have a configurable object that takes
yeah we can easily do that
we probably should :)
Andy Holland
@AMHOL
:+1:
Tim Riley
@timriley
@gotar I'll be at work in 40 minutes - will look into this stuff for you right away
@solnic I don't quite see how the explicit require and accessing an object via a constant implies it's a boundary enforcer... Repos also demarcate boundaries, for example, but we don't do it for those...
Piotr Solnica
@solnic
not really an enforcer, just a signal that it's a concrete dependency being a boundary
repos are objects because it's better to have them as abstract stuff, this is 100 x bigger than a small object validating data (well ok a schema is big but not even close to the size of a repo object giving you access to data in your db including data mutation interfaces)
besides if these were not objects we would have to stick globals like db connections to classes etc, do-not-like
Tim Riley
@timriley
So concrete dependency == something that's just not another internal object in our app's core, something a bit more "foreign"
Is that kinda what you're saying?
Piotr Solnica
@solnic
wdym by "foreign"?
Tim Riley
@timriley
Foreign as is not quite like the other objects that comprise our app's core behavior, all of which are in the container. Foreign as in a bit like using another gem, even.
Piotr Solnica
@solnic
haven't thought about it like that
Tim Riley
@timriley
I can't equate it to the explicit require etc. we need for instantiatiiself value objects, because this is still a functional object and could be in our container
Piotr Solnica
@solnic
foreign as in external to the app's container, yes, of course
Tim Riley
@timriley
Yeah, that's what I meant
Piotr Solnica
@solnic
I think about schemas as types too
Tim Riley
@timriley
I'm gonna need to come up with a different injection scenario for my talk, haha
Piotr Solnica
@solnic
it's an fp object that responds to call but it also very strictly defines a very specific type of data that your app deals with
Tim Riley
@timriley
Yeah, I think I'm starting to get you now
Piotr Solnica
@solnic
so even though we don't instantiate an instance of that "type" a schema still defines "a type"
I can say exactly the same thing about domain types defined by dry-types structs and values
Tim Riley
@timriley
This is true!
Piotr Solnica
@solnic
it's just that source data for these types come from a db, not an http request
Tim Riley
@timriley
Yeah. And I don't care abut injecting them because there are so many. It's completely unwarranted.
So I guess the same rule can apply to schemas
Piotr Solnica
@solnic
yeah, I think DI is a good tool for "service objects"
as in stuff that does something heavy, esp with side-effects
and you may want to replace it, or decorate it, or sutin
Tim Riley
@timriley
Yeah
I hear you
Oskar Szrajer
@gotar
ok all looks to work (basic skeleton), but a little magic to drop in next step
^ magic here ;]
@timriley your blog posts and repos was a HUGE help
it's so kard to glue everything together for the first time, a lot more blog posts and docs needed
Tim Riley
@timriley
@gotar oh cool! So you've got it now?
@gotar yeah, I hope I can write some more stack-specific docs over the next 2 weeks. And my blog posts... Well, they'll get there eventually. They have a plodding pace :)
Oskar Szrajer
@gotar
I manage it somehow but not happy how ;]
Tim Riley
@timriley
Hah, so have you had to use a hack or something? Or it just took longer than you hoped to get to the solution?