These are chat archives for dry-rb/chat

10th
Jun 2017
Andrew Kozin
@nepalez
Jun 10 2017 20:52
Hi! @flash-gordon @kwando what d'you mean when mention with? Is that a sort of with_options in AR::Validations ?
Nikita Shilnikov
@flash-gordon
Jun 10 2017 21:11
@nepalez in some dry/rom gems we established a convention of initializing a copy of an object that doesn't have a mutable state. Very similar to how Hash#merge works, for example, relation.with(name: relation.name.as(:alias)) gives you a full copy of the relation object with changed :name. We'd be happy to see it in dry-initializer OOTB, wdyt?
Can be as simple as def with(new_options) self.class.new(*params, options.merge(new_options))