Sha256: 078669b59a0925fd268c25010c60b88c2854b7c9aaef70666be7c0b30d2d766c
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module VestalVersions # Allows version creation to occur conditionally based on given <tt>:if</tt> and/or # <tt>:unless</tt> options. module Deletion extend ActiveSupport::Concern included do before_destroy :create_destroyed_version, :if => :delete_version? end # Class methods on ActiveRecord::Base module ClassMethods # After the original +prepare_versioned_options+ method cleans the given options, this alias # also extracts the <tt>:depedent</tt> if it set to <tt>:tracking</tt> def prepare_versioned_options(options) result = super(options) if result[:dependent] == :tracking self.vestal_versions_options[:track_destroy] = true options.delete(:dependent) end result end end module InstanceMethods private def delete_version? vestal_versions_options[:track_destroy] end def create_destroyed_version create_version({:modifications => attributes, :number => last_version + 1, :tag => 'deleted'}) end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
set_vestal_versions-1.2.2 | lib/vestal_versions/deletion.rb |
razenha-vestal_versions-1.2.2 | lib/vestal_versions/deletion.rb |