revisions 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/revisions.rb +8 -6
- data/revisions.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/lib/revisions.rb
CHANGED
@@ -37,18 +37,20 @@ module Revisions
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def save_revision
|
40
|
-
new_copy = self.
|
41
|
-
|
42
|
-
self.unrevised_attributes.each {|a|
|
43
|
-
new_copy.attributes=
|
40
|
+
new_copy = self.class.new
|
41
|
+
cloned_attributes = self.clone_attributes
|
42
|
+
self.unrevised_attributes.each {|a| cloned_attributes.delete(a) }
|
43
|
+
new_copy.attributes=cloned_attributes
|
44
44
|
new_copy.created_at = new_copy.updated_at = Time.zone.now
|
45
45
|
new_copy.status = 'revision'
|
46
46
|
new_copy.revision_of = self.id
|
47
|
-
new_copy.id = nil # makes it compatible with rails 3.0, which dupes the id.
|
48
47
|
if new_copy.save
|
49
48
|
true
|
50
49
|
else
|
51
|
-
|
50
|
+
self.errors.clear
|
51
|
+
new_copy.errors.each do |attribute,message|
|
52
|
+
self.errors[attribute] << message
|
53
|
+
end
|
52
54
|
false
|
53
55
|
end
|
54
56
|
end
|
data/revisions.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: revisions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Hamman
|