Module: VestalVersions::Reset
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/vestal_versions/reset.rb
Overview
Adds the ability to “reset” (or hard revert) a versioned ActiveRecord::Base instance.
Instance Method Summary collapse
-
#reset_to!(value) ⇒ Object
Adds the instance methods required to reset an object to a previous version.
Instance Method Details
#reset_to!(value) ⇒ Object
Adds the instance methods required to reset an object to a previous version. Similar to revert_to!
, the reset_to!
method reverts an object to a previous version, only instead of creating a new record in the version history, reset_to!
deletes all of the version history that occurs after the version reverted to.
The action taken on each version record after the point of reversion is determined by the :dependent
option given to the versioned
method. See the versioned
method documentation for more details.
14 15 16 17 18 19 20 |
# File 'lib/vestal_versions/reset.rb', line 14 def reset_to!(value) if saved = skip_version{ revert_to!(value) } association(:versions).send(:delete_records, versions.after(value), self.class.reflect_on_association(:versions).[:dependent]) reset_version end saved end |