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

Add reify_original method. #1504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joshuapinter
Copy link

Returning the original version is a common use-case and is not as easy as it should be, particularly because calling reify on the first version returns nil, which is the object before it was created.

This method simply tries to reify from the second version, if it exists. If it doesn’t exist (i.e. there has not been any changes to the object), it falls back to self, which is the original and only version of the object.

Fixes #1204.

Thank you for your contribution!

Check the following boxes:

  • Wrote good commit messages.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new
    code introduces user-observable changes.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.

Returning the original version is a common use-case and is not as easy as it should be, particularly because calling `reify` on the first version returns `nil`, which is the `object` *before* it was created.

This method simply tries to `reify` from the *second* version, if it exists. If it doesn’t exist (i.e. there has not been any changes to the object), it falls back to `self`, which is the original and *only* version of the object.

Fixes paper-trail-gem#1204.
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.

Add original_version method to more easily obtain the original version.
1 participant