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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 047e72c287edac9652bb432b71b3fe4b2e0e7822
4
- data.tar.gz: fe7bcfe8813faff091440a3f591467c6d6c79dc0
2
+ SHA256:
3
+ metadata.gz: f5fd72c704029f1ac448fd1a967dbd2eda1f4dec27d546750028142abc8bb985
4
+ data.tar.gz: afe134b29057b8b71cc1417aa3ecbdf1787cc525c4a213ac476b842ee4d753c5
5
5
  SHA512:
6
- metadata.gz: 07329646bcc03cfc94c4687339bf3f6296f3ddf85c8ec3c4d11114b72f15eb6c0dc0cd10492e35288c7c3a105b9ed958ec7f7fec9f32faee923376ae19f4133d
7
- data.tar.gz: e09f2bf36bd530e5894c51f3c4cc575e6fe11e346acc395d00eea6afd08b277ec8af2285e5f77b7f75f233a45145e00348af80adcb4dc965857fb945425471b2
6
+ metadata.gz: 6980036d44de51492bbbfa4d2e2884e4211304d05295d9940f1f091097d4e9451106bd3184c579bf2d10a2bf8d446cf0a7ba9dfb269aadf674d574091e561b25
7
+ data.tar.gz: 318ad20132eba3f0ad172d6b717d3c1b1b8fd28eecdc2f8726fa817cddd8dc6e8723781737ec398c7052229792128083f955fa06a6d7623953f17127cfb86f8e
@@ -1,3 +1,3 @@
1
1
  module AttributesHistory
2
- VERSION = '0.0.3'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -14,7 +14,7 @@ module AttributesHistory
14
14
  private
15
15
 
16
16
  def history_attributes_changed?
17
- (@object.changed & @history_attributes).present?
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.in?(@object.changed)
39
- @object.changes[attribute].first
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.3
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: 2015-12-21 00:00:00.000000000 Z
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: 4.2.5
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: 4.2.5
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.4.0
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.4.0
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.4.8
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: