Module | VestalVersions::Reversion::InstanceMethods |
In: |
lib/vestal_versions/reversion.rb
|
Provides the base instance methods required to revert a versioned instance.
Accepts a value corresponding to a specific version record, builds a history of changes between that version and the current version, and then iterates over that history updating the object‘s attributes until the it‘s reverted to its prior state.
The single argument should adhere to one of the formats as documented in the at method of VestalVersions::Versions.
After the object is reverted to the target version, it is not saved. In order to save the object after the reversion, use the +revert_to!+ method.
The version number of the object will reflect whatever version has been reverted to, and the return value of the revert_to method is also the target version number.
Behaves similarly to the revert_to method except that it automatically saves the record after the reversion. The return value is the success of the save.