Skip to content

Add reify_original method. #1504

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

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

Conversation

joshuapinter
Copy link

@joshuapinter joshuapinter commented Jan 8, 2025

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.

Copy link

github-actions bot commented Apr 9, 2025

This PR has been automatically marked as stale due to inactivity.
The resources of our volunteers are limited.
If this is something you are committed to continue working on, please address any concerns raised by review and/or ping us again.
Thank you for all your contributions.

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.

Added specs to document, legacy widget and widget.

Fixes paper-trail-gem#1204.
@joshuapinter
Copy link
Author

Okay, I've added specs and an entry into the CHANGELOG. This PR should be ready for review and merging.

Let me know if you would like to see any changes.

Thanks.

@github-actions github-actions bot removed the Stale label Apr 10, 2025
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