track_history 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/track_history.rb +9 -2
- data/lib/track_history/version.rb +1 -1
- metadata +6 -6
data/lib/track_history.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module TrackHistory
|
2
2
|
|
3
3
|
autoload :VERSION, File.join(File.dirname(__FILE__), 'track_history', 'version')
|
4
|
+
require 'rubygems'
|
4
5
|
require 'active_record'
|
5
6
|
|
6
7
|
def self.install
|
@@ -64,8 +65,8 @@ module TrackHistory
|
|
64
65
|
|
65
66
|
# tell the other class about us
|
66
67
|
# purposely don't define these until after getting historical_fields
|
67
|
-
has_many :histories, :class_name => class_name, :order => 'created_at desc'
|
68
|
-
|
68
|
+
has_many :histories, :class_name => class_name, :order => 'created_at desc', :dependent => :destroy
|
69
|
+
before_update :record_historical_changes
|
69
70
|
|
70
71
|
end
|
71
72
|
|
@@ -80,6 +81,12 @@ module TrackHistory
|
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
84
|
+
def to_s
|
85
|
+
modifications.map do |field|
|
86
|
+
"#{field}: " + send(:"#{field}_before") + '=>' + send(:"#{field}_after")
|
87
|
+
end.join(', ')
|
88
|
+
end
|
89
|
+
|
83
90
|
end
|
84
91
|
|
85
92
|
module InstanceMethods
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: track_history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Crepezzi
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-06 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements: []
|
74
74
|
|
75
75
|
rubyforge_project: historical
|
76
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.4.1
|
77
77
|
signing_key:
|
78
78
|
specification_version: 3
|
79
79
|
summary: Smart model auditing
|