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

Version#reify return new object instance with dup: true options #399

Merged
merged 1 commit into from
Jul 25, 2014

Conversation

mourad-ifeelgoods
Copy link
Contributor

If we want to compare two arbitrary versions, we can use version#reify to retrieve the model from the version, and then creating a diff between the models (with activerecord-diff for example)

widget = Widget.find(1)
reified_widget1 = widget.versions[0].reify
reified_widget2 = widget.versions[3].reify
changes = reified_widget1.diff(reified_widget2)

This strategy fail because reify will not create a new instance. reified_widget1 and reified_widget2 are the same object. for this purpose it is possible to call reify with :dup true to return a new instance

@batter
Copy link
Collaborator

batter commented Jul 25, 2014

This looks good, the only thing I question is whether it makes sense to do this all the time? I guess not because it's probably a bit more expensive to do this, huh?

@batter batter added this to the 3.1.0 milestone Jul 25, 2014
@batter batter self-assigned this Jul 25, 2014
@batter batter merged commit 1cc1d7a into paper-trail-gem:master Jul 25, 2014
batter added a commit that referenced this pull request Jul 25, 2014
batter added a commit that referenced this pull request Aug 29, 2014
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

Successfully merging this pull request may close these issues.

2 participants