freerange_acts_as_versioned 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/acts_as_versioned.gemspec +2 -2
- data/lib/acts_as_versioned.rb +14 -0
- metadata +4 -4
data/acts_as_versioned.gemspec
CHANGED
|
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
|
14
14
|
## the sub! line in the Rakefile
|
|
15
15
|
s.name = 'freerange_acts_as_versioned'
|
|
16
|
-
s.version = '0.
|
|
17
|
-
s.date = '
|
|
16
|
+
s.version = '0.8.0'
|
|
17
|
+
s.date = '2012-04-23'
|
|
18
18
|
s.rubyforge_project = 'freerange_acts_as_versioned'
|
|
19
19
|
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/acts_as_versioned.rb
CHANGED
|
@@ -280,6 +280,19 @@ module ActiveRecord #:nodoc:
|
|
|
280
280
|
rev.save
|
|
281
281
|
end
|
|
282
282
|
end
|
|
283
|
+
|
|
284
|
+
# Saves a version of the model in the versioned table. This is called in the after_save callback by default
|
|
285
|
+
def auto_save_version
|
|
286
|
+
if @saving_version
|
|
287
|
+
@saving_version = nil
|
|
288
|
+
rev = self.class.versioned_class.new
|
|
289
|
+
clone_versioned_model(self, rev)
|
|
290
|
+
rev.send("#{self.class.version_column}=", send(self.class.version_column))
|
|
291
|
+
rev.send("#{self.class.versioned_foreign_key}=", id)
|
|
292
|
+
rev.send("autosave=", true)
|
|
293
|
+
rev.save
|
|
294
|
+
end
|
|
295
|
+
end
|
|
283
296
|
|
|
284
297
|
# Clears old revisions if a limit is set with the :limit option in <tt>acts_as_versioned</tt>.
|
|
285
298
|
# Override this method to set your own criteria for clearing old versions.
|
|
@@ -422,6 +435,7 @@ module ActiveRecord #:nodoc:
|
|
|
422
435
|
self.connection.create_table(versioned_table_name, create_table_options) do |t|
|
|
423
436
|
t.column versioned_foreign_key, :integer
|
|
424
437
|
t.column version_column, :integer
|
|
438
|
+
t.column :autosave, :boolean , :default => false
|
|
425
439
|
end
|
|
426
440
|
|
|
427
441
|
self.versioned_columns.each do |col|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: freerange_acts_as_versioned
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 63
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
8
|
+
- 8
|
|
9
9
|
- 0
|
|
10
|
-
version: 0.
|
|
10
|
+
version: 0.8.0
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Abdul Rauf
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
18
|
+
date: 2012-04-23 00:00:00 +09:30
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|