Sha256: 5938b781c1169f4cf23fb66e839a2f72f1802f77ec9662c3bdafc30dd24f6b4c
Contents?: true
Size: 1017 Bytes
Versions: 3
Compression:
Stored size: 1017 Bytes
Contents
module VestalVersions # Adds the ability to "reset" (or hard revert) a versioned ActiveRecord::Base instance. module Reset extend ActiveSupport::Concern # 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 # <tt>:dependent</tt> option given to the +versioned+ method. See the +versioned+ method # documentation for more details. 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).options[:dependent]) reset_version end saved end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
geothird_vestal_versions-1.2.5 | lib/vestal_versions/reset.rb |
geothird_vestal_versions-1.2.4 | lib/vestal_versions/reset.rb |
geothird_vestal_versions-1.2.3 | lib/vestal_versions/reset.rb |