Module: ActsAsArchive::Base::ActMethods

Defined in:
lib/acts_as_archive/base.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_archive(options = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/acts_as_archive/base.rb', line 9

def acts_as_archive(options={})
  class_eval <<-end_eval
    
    def self.acts_as_archive?
      self.to_s == #{self.to_s.inspect}
    end
    
    def self.archive_indexes
      #{Array(options[:indexes]).map{|index| index.is_a?(Array) ? index.map(&:to_sym) : index.to_sym}.inspect}
    end
    
    class Archive < ActiveRecord::Base
      self.record_timestamps = false
      self.table_name = "archived_#{self.table_name}"
    end
  end_eval
  include Destroy
  include Restore
  include Table
end