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

Open
rpiaggio opened this issue Apr 17, 2018 · 3 comments
Open

Patching from another instance of the same case class #57

rpiaggio opened this issue Apr 17, 2018 · 3 comments
Labels
blocked Ticket cannot be implemented because it depends on another ticker or external factor 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Ticket cannot be implemented because it depends on another ticker or external factor dragons ahead Task which requires handwriting compiletime reflection for Scala2&3 and/or updating the architecture enhancement
Projects
None yet
Development

No branches or pull requests

3 participants