Comments (4)
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.
from virtus.
You mean like https://github.com/solnic/virtus-dirty_tracking ?
from virtus.
@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).
from virtus.
@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.
from virtus.
Related Issues (20)
- Publish 1.0.6
- Avoid override of previously assigned attributes
- Put link to dry-rb in README.md to save time for new comers
- possible to dynamically add attributes? HOT 1
- What replaces `ValueObject::InstanceMethods::with`?
- Class not getting initialized HOT 1
- Bug: nil default value of Array attribute ignored HOT 1
- Coerce proc and strict mode don't match
- Default values aren't assigned when initialize method is present. HOT 1
- Array of Array of FooClass
- Strange Boolean behaviour HOT 5
- Validation from class attributes
- Show Embedded value on edit form
- Calling methods inside of a Virtus::Attribute
- Mark as unmaintaned HOT 2
- Hash.try_convert(attributes) errors on params in Rails 5
- FixedWidth Coercion HOT 2
- Date formats HOT 1
- How can I use array of tags(Strings) in a key of a hash? HOT 1
- Strict mode only works for basic values HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from virtus.