GitHub - flajann2/deep_dive: DeepDive is a ruby gem that allows you to deep copy your object graphs in a controlled way. You can specify which instance variables to skip over in the duplication, which will just leave the original reference to them in the copy.
DeepDive is a ruby gem that allows you to deep copy your object graphs in a controlled way. You can specify which instance variables to skip over in the duplication, which will just leave the original reference to them in the copy.
Want to be notified of new releases in flajann2/deep_dive?
When you have a system of objects that have many references to each other, it becomes an issue to be able to clone properly that object graph. There may be control objects you may not want to clone, but maintain references to. And some references you may not wish to clone at all.
Enter DeepDive. Allows you a means by which you can do controlled deep cloning or copying of your complex interconnected objects.
Simply include DeepDive in your base class. All classes derived will be set for deep cloning or deep duping.
in which case you will get a dump to stdout of all the classes of the objects it copies, which can be copious depending on your application.
@foo.changeme = @bar.changeme = @foobar.changeme = "initial"
@foo.c will refer to the same object as nfoo.c, but @foo.b and nfoo.b will be different, as nfoo.b will be a deep clone of @foo.b.
which will basically do a deep dup of @foo.
Please see spec/lib/deep_dive/deep_dive_spec.rb for a more comprehensve example of the above. Better documentation will be supplied shortly.
In some rare circumstances, you may need to patch an instance variable in your object graph during deep copying. Like for instance, when a child object is being cloned seprately from a different parent to be associated with a new parent.
And all variables named "parent" in the object graph will pick up the new reference.
DeepDive is expected to undergo "rapid" evolution until it hits 1.0.0. I will take every effort to keep the API backwards compatable until then. Thing is, DeepDive seems to be relatively stable anyway. As the RubyNEAT project is driving the features of deep_dive, we may see more exotic features in the near future.
Rails is driving much of the Ruby landscape these days. Alas, I have yet to test DeepDive in that context. In theory, it should just work fine, but I suspect there will need to be special treatment, especially with ActiveRecord type objects. Feel free to raise issues here so I can address them.
2015-07-07 0.3.0 – Added debugging and deep patching based on instance variable names.
2014-07-27 0.2.0 – Implemented the exclusion block, made gem restrictive to Ruby 2.x and higher.
I wish to conver this document to org format someday.
I wish to fully support Rails and some of the special issues that may arise there.
Copyright © 2013-2016 Fred Mitchell. See LICENSE.txt for further details.