attributes_history 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/attributes_history/gem_version.rb +1 -1
- data/lib/attributes_history/history_saver.rb +11 -3
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f5fd72c704029f1ac448fd1a967dbd2eda1f4dec27d546750028142abc8bb985
|
4
|
+
data.tar.gz: afe134b29057b8b71cc1417aa3ecbdf1787cc525c4a213ac476b842ee4d753c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6980036d44de51492bbbfa4d2e2884e4211304d05295d9940f1f091097d4e9451106bd3184c579bf2d10a2bf8d446cf0a7ba9dfb269aadf674d574091e561b25
|
7
|
+
data.tar.gz: 318ad20132eba3f0ad172d6b717d3c1b1b8fd28eecdc2f8726fa817cddd8dc6e8723781737ec398c7052229792128083f955fa06a6d7623953f17127cfb86f8e
|
@@ -14,7 +14,7 @@ module AttributesHistory
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def history_attributes_changed?
|
17
|
-
(
|
17
|
+
(changes.keys & @history_attributes).present?
|
18
18
|
end
|
19
19
|
|
20
20
|
def save_history_entry
|
@@ -35,11 +35,19 @@ module AttributesHistory
|
|
35
35
|
|
36
36
|
def history_value_for(attribute)
|
37
37
|
# Use the previous value if it was changed, otherwise the current value
|
38
|
-
if attribute
|
39
|
-
|
38
|
+
if changes[attribute]
|
39
|
+
changes[attribute].first
|
40
40
|
else
|
41
41
|
@object.public_send(attribute)
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
def changes
|
46
|
+
if Gem::Version.new(Rails.version) >= Gem::Version.new('5.1.0')
|
47
|
+
@object.saved_changes
|
48
|
+
else
|
49
|
+
@object.changes
|
50
|
+
end
|
51
|
+
end
|
44
52
|
end
|
45
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attributes_history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- draffensperger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -56,28 +56,28 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: 5.1.0
|
60
60
|
type: :development
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
version: 5.1.0
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: rspec-rails
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 3.
|
73
|
+
version: 3.8.0
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
78
|
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: 3.
|
80
|
+
version: 3.8.0
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rubocop
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,9 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
172
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
173
|
+
rubygems_version: 2.7.8
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
176
|
summary: Date-granular history for specified model fields. Compact & easy to query.
|
177
177
|
test_files: []
|
178
|
-
has_rdoc:
|