Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching from another instance of the same case class #57

Closed
rpiaggio opened this issue Apr 17, 2018 · 4 comments · Fixed by #614
Closed

Patching from another instance of the same case class #57

rpiaggio opened this issue Apr 17, 2018 · 4 comments · Fixed by #614
Labels
dragons ahead Task which requires handwriting compiletime reflection for Scala2&3 and/or updating the architecture enhancement

Comments

@rpiaggio
Copy link

rpiaggio commented Apr 17, 2018

Thank you for this great library! It's incredibly useful together with Diode+React.

Here's a suggestion, which I think naturally falls within the domain of chimney: Being able to patch a case class instance from another instance, specifying the fields to patch. It can be seen as nicer syntax for .copy(...) specifying override fields from the other instance.

For example:

user.patchFrom(anotherUser, _.email, _.phone, _.address)

which would be equivalent to:

user.copy(email = anotherUser.email, phone = anotherUser.phone, address = anotherUser.address)

Thank you!

@krzemin
Copy link
Member

krzemin commented Apr 17, 2018

Sounds good 👍

@rpiaggio
Copy link
Author

Thank you @krzemin. Upon further thought, the patcher could be abstracted away for reusability (or reusability of the code that applies it):

val patcher = PatcherFor[User](_.email, _.phone, _.address)
user.patchFrom(patcher)(anotherUser)

(Might make sense to curry the application too).

@krzemin krzemin added this to the 0.2.x milestone Apr 19, 2018
@krzemin krzemin removed this from the 0.2.x milestone Nov 23, 2018
@MateuszKubuszok MateuszKubuszok added the dragons ahead Task which requires handwriting compiletime reflection for Scala2&3 and/or updating the architecture label Oct 20, 2023
@MateuszKubuszok MateuszKubuszok added this to the Merge transformations milestone Dec 19, 2023
@MateuszKubuszok MateuszKubuszok changed the title [Feature request/Suggestion] Patching from another instance of the same case class Patching from another instance of the same case class May 19, 2024
@MateuszKubuszok
Copy link
Member

Depends on #538 which in turns depends on #115.

@MateuszKubuszok MateuszKubuszok added the blocked Ticket cannot be implemented because it depends on another ticker or external factor label May 19, 2024
@MateuszKubuszok MateuszKubuszok removed the blocked Ticket cannot be implemented because it depends on another ticker or external factor label Jan 23, 2025
@MateuszKubuszok
Copy link
Member

The functionality is available on master, see testing-snapshots if you want to help us testing it (and checking if the documentation makes sense) before we'll release it (I want to do a few much smaller things before the release).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dragons ahead Task which requires handwriting compiletime reflection for Scala2&3 and/or updating the architecture enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants