17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/archivist/base.rb', line 17
def has_archive(options={})
options = ARCHIVIST_DEFAULTS.merge(options)
options[:allow_multiple_archives] = true if options[:associate_with_original]
class_eval(%Q{
alias_method :delete!, :delete
class << self
alias_method :delete_all!, :delete_all
def archive_indexes
#{Array(options[:indexes]).collect{|i| i.to_s}.inspect}
end
def archive_options
#{options.inspect}
end
def has_archive?
true
end
def acts_as_archive?
warn("DEPRECATION WARNING: #acts_as_archive is provided for compatibility with AAA and will be removed soon, please use has_archive?",caller )
has_archive?
end
end
class Archive < ActiveRecord::Base
self.record_timestamps = false
self.table_name = "archived_#{self.table_name}"
self.primary_key = "#{self.primary_key}"
include Archivist::ArchiveMethods
end
#{build_copy_self_to_archive(options[:allow_multiple_archives])}
},File.expand_path(__FILE__),21)
if ActiveRecord::VERSION::STRING >= "3.1.0"
enable_archive_mass_assignment!(self)
end
attach_serializations!(self)
include_modules!(self,options[:included_modules]) if options[:included_modules]
build_associations!(self) if options[:associate_with_original]
include InstanceMethods
extend ClassExtensions
include DB
end
|