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

Plans for dirty tracking? #42

Closed
emmanuel opened this issue Nov 21, 2011 · 4 comments
Closed

Plans for dirty tracking? #42

emmanuel opened this issue Nov 21, 2011 · 4 comments

Comments

@emmanuel
Copy link
Collaborator

Are there any plans to implement dirty tracking support in Virtus? I can do what I want without it, but it would be handy in some circumstances.

I believe the plan with DM2 is to manage dirty tracking in a UnitOfWork/Session object, but I'd like it for non-persistent objects.

@dkubb
Copy link
Collaborator

dkubb commented Nov 21, 2011

What would be the use case for non-persistent objects? In a non-persistent environment, would some kind of observer system where you could register code for handling on-change events give you the ability to do the same thing? If you had some way to observe events, then tracking them in a UnitOfWork would be relatively simple.

One other thing I would like to add, is that if we were going to add observers or dirty tracking I would much rather see it being handled outside of the virtus gem. I think virtus almost does as much as it needs to, and I would even propose that the heavy lifting in the coercions system should be extracted.

Virtus, like DataMapper and ActiveRecord/ActiveModel give people this really convenient place to hang extra behaviour from. It's all-too-easy to keep adding more and more behaviour into Virtus. I think everything we do should be considered if it would be possible to add to regular Ruby objects, and if it can, then it should be done first.. then if we need any glue code to make it work with Virtus we can add that second.

@namelessjon
Copy link

You mean like https://github.com/solnic/virtus-dirty_tracking ?

@solnic
Copy link
Owner

solnic commented Nov 21, 2011

@emmanuel As @namelessjon points out I already wrote a plugin for DT although it was just a quick code spike to test a different approach than what we have in dm-core/dm-types at the moment.

I'm still not sure if DT should be a part of virtus or a virtus plugin. As @dkubb writes we're dealing with a non-persistent environment so it's hard to justify why you would need dirty tracking. We briefly talked about it with @dkubb and kind of agreed that DT should be a part of UoW/Session which will not be coupled with Virtus (if I remember correctly).

@emmanuel
Copy link
Collaborator Author

@namelessjson — Thanks for the pointer!

Between virtus-dirty_tracking and rethinking my approach, I've realized I don't need general-purpose dirty tracking in Virtus.

Also, I agree that dirty-tracking on non-persistent objects is probably not a widespread use-case, and probably shouldn't be in Virtus itself in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants