These are chat archives for dry-rb/chat

13th
Oct 2017
Dmitry P
@fenec
Oct 13 2017 05:50
@achernik thx! not sure how I missed it
Piotr Solnica
@solnic
Oct 13 2017 08:36
@achernik trigger is in place, but we're not using it yet
Ahmad A.Elghany
@ahmgeek
Oct 13 2017 14:02
hey guys, I think you got this question a lot, but, here's one more, let's say I got the model which have the data from a repository or the db directly or whatever the source of the data, and now I need to change for instance some attributes, let's assume it's deleted_at, or just updated_at and another attribute like boolean to false or something. the way I do it is like to_h the model, and manipulate the data, then initialize it into new model, but the code turned to be repetitive and ugly, or maybe its just me who sense there's something better should be used there, I think you got to this point too, so what are you do in favour to solve this?
Nikita Shilnikov
@flash-gordon
Oct 13 2017 14:07
@ahmgeek by saying "model" you mean a dry-struct object?
Ahmad A.Elghany
@ahmgeek
Oct 13 2017 14:11
yup, sorry
Nikita Shilnikov
@flash-gordon
Oct 13 2017 14:12
then existing_struct.new(attr: new_value)
Gustavo Caso
@GustavoCaso
Oct 13 2017 14:12
@ahmgeek dry-struct should not be modify
They are value objects
Peter Leitzen
@splattael
Oct 13 2017 14:14
Question about dry-system: Is there a reason why the MyApp::Container should be defined under system/my_app/container.rb and not via lib/my_app/container.rb? Example: https://github.com/icelab/berg/blob/master/system/berg/container.rb
Markus Unterwaditzer
@untitaker
Oct 13 2017 14:14
@flash-gordon let's rephrase the question: assuming I have code like new_value = MyStruct.new(old_value.to_h.merge(new_attribute: 42)), how can I change this such that dry-rb doesn't revalidate all attributes, but only the changed ones?
ah, nvm
that was unsurprisingly hard to find in the docs :P
Nikita Shilnikov
@flash-gordon
Oct 13 2017 14:19
@untitaker hm, this is not supported yet, values are always get validated, we could/should do something about it. Can you file and issue about it on gh? We'd talk about it there at least
since all attributes are independent from each other this should be doable
Ahmad A.Elghany
@ahmgeek
Oct 13 2017 14:20
@flash-gordon oh boy, if it wasn't @untitaker I wouldn't knew that instances have new
Markus Unterwaditzer
@untitaker
Oct 13 2017 14:21
@flash-gordon could be an optimization of the instance-method new, right? Not really a new API
Nikita Shilnikov
@flash-gordon
Oct 13 2017 14:21
right