Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Commented out the loading of acts as archive from within the gem so

that it can be loaded within an intitializer instead. Changed the
::Archive class to inherit from self so that the class can benifit from
it's parents methods.
  • Loading branch information...
commit 361adb0c397c7766683d2233bd552f4b50d6abc6 1 parent 077f09f
authored April 20, 2011
14  lib/acts_as_archive.rb
@@ -116,25 +116,25 @@ def acts_as_archive(options={})
116 116
             klass.send :set_table_name, options[:table]
117 117
           else
118 118
             eval <<-EVAL
119  
-              class ::#{options[:class]} < ActiveRecord::Base
  119
+            class ::#{options[:class]} < self
120 120
                 set_table_name "#{options[:table]}"
121  
-              end
  121
+            end
122 122
             EVAL
123 123
             klass = eval("::#{options[:class]}")
124 124
           end
125 125
           
126 126
           klass.record_timestamps = options[:timestamps].inspect
127 127
           klass.acts_as_archive(:class => self, :archive => true)
128  
-        
  128
+          
129 129
           self.reflect_on_all_associations.each do |association|
130  
-            if !ActsAsArchive.find(association.klass).empty? && association.options[:dependent]
  130
+            if !!(association.options[:dependent] && !association.options[:polymorphic] && !ActsAsArchive.find(association.klass).empty?)
131 131
               opts = association.options.dup
132 132
               opts[:class_name] = "::#{association.class_name}::Archive"
133 133
               opts[:foreign_key] = association.primary_key_name
134 134
               klass.send association.macro, association.name, opts
135 135
             end
136 136
           end
137  
-        
  137
+          
138 138
           unless options[:migrate] == false
139 139
             AlsoMigrate.configuration ||= []
140 140
             AlsoMigrate.configuration << options.merge(
@@ -209,7 +209,7 @@ def delete_sql_with_archive(sql, name = nil)
209 209
           unless ActsAsArchive.disabled
210 210
             from, where = /DELETE FROM (.+)/i.match(sql)[1].split(/\s+WHERE\s+/i, 2)
211 211
             from = from.strip.gsub(/`/, '').split(/\s*,\s*/)
212  
-        
  212
+            
213 213
             ActsAsArchive.find(from).each do |config|
214 214
               ActsAsArchive.move(config, where)
215 215
             end
@@ -226,4 +226,4 @@ def delete_sql_with_archive(sql, name = nil)
226 226
 ::ActiveRecord::ConnectionAdapters::DatabaseStatements.send(:include, ::ActsAsArchive::DatabaseStatements)
227 227
 
228 228
 require "acts_as_archive/adapters/rails#{Rails.version[0..0]}" if defined?(Rails)
229  
-require "acts_as_archive/adapters/sinatra" if defined?(Sinatra)
  229
+require "acts_as_archive/adapters/sinatra" if defined?(Sinatra)
2  lib/acts_as_archive/adapters/rails2.rb
... ...
@@ -1 +1 @@
1  
-ActsAsArchive.load_from_yaml(Rails.root)
  1
+# ActsAsArchive.load_from_yaml(Rails.root)

0 notes on commit 361adb0

Please sign in to comment.
Something went wrong with that request. Please try again.