journaled 1.0.1 → 2.0.0.alpha1

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
2
  SHA1:
3
- metadata.gz: 878b6e83aa7e165d108ec09b1faca07c1576e9a8
4
- data.tar.gz: f9ab27442fc7579393c5073a3bbe99792b304dc5
3
+ metadata.gz: 4ee54a77497db5d43b3932d6015b18b6b2c4ae45
4
+ data.tar.gz: 6fc6bed161faf09676c7578531eb563a47ee9e6b
5
5
  SHA512:
6
- metadata.gz: 20fddb8c7405abcfb51c84254940a97e99e8f10d710042c479f75db57d0e681e86762bdc6d12bfa63940de79458748373c2060b2cb7f739e66ea579d15703c34
7
- data.tar.gz: 22a24cb455b41e770851638a88ef487bdace075399927f3e377866e32541e1cf8b8df01335032fa6248433719cbe4b65d71af3b6ee797f76779c56e9639eae50
6
+ metadata.gz: 030301523134d5a36c15de4e7096917c9d948c00c1514c41c9e82ff0184f358f9c346786e9f1757d229c0050073f996b03ff2bac038a7a773a9f9c02bd56bd5a
7
+ data.tar.gz: a6d3c21d82902e96f3486b3637365b20d0803a11ece98260121bc80b73555bf823b3eaf6731ba82daa8c83e6044f815793e4c5d73c996d8606eed7f0dec85f5a
@@ -16,11 +16,11 @@ class Journaled::ChangeWriter
16
16
  end
17
17
 
18
18
  def update
19
- journaled_change_for("update", relevant_changes).journal! if relevant_changes.present?
19
+ journaled_change_for("update", relevant_changed_attributes).journal! if relevant_changed_attributes.present?
20
20
  end
21
21
 
22
22
  def delete
23
- journaled_change_for("delete", {}).journal!
23
+ journaled_change_for("delete", relevant_unperturbed_attributes).journal!
24
24
  end
25
25
 
26
26
  def journaled_change_for(database_operation, changes)
@@ -39,10 +39,12 @@ class Journaled::ChangeWriter
39
39
  model.attributes.slice(*attribute_names)
40
40
  end
41
41
 
42
- def relevant_changes
43
- relevant_changes_with_previous_values.each_with_object({}) do |(k, v), result|
44
- result[k] = v[1]
45
- end
42
+ def relevant_unperturbed_attributes
43
+ model.attributes.merge(pluck_changed_values(model.changes, index: 0)).slice(*attribute_names)
44
+ end
45
+
46
+ def relevant_changed_attributes
47
+ pluck_changed_values(model.saved_changes.slice(*attribute_names), index: 1)
46
48
  end
47
49
 
48
50
  def actor_uri
@@ -67,8 +69,10 @@ class Journaled::ChangeWriter
67
69
  end
68
70
  end
69
71
 
70
- def relevant_changes_with_previous_values
71
- model.saved_changes.slice(*attribute_names)
72
+ def pluck_changed_values(change_hash, index:)
73
+ change_hash.each_with_object({}) do |(k, v), result|
74
+ result[k] = v[index]
75
+ end
72
76
  end
73
77
 
74
78
  def journaled_app_name
@@ -1,3 +1,3 @@
1
1
  module Journaled
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "2.0.0.alpha1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: journaled
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Lipson
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-01-31 00:00:00.000000000 Z
14
+ date: 2019-02-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: aws-sdk-resources
@@ -228,9 +228,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  version: '0'
229
229
  required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  requirements:
231
- - - ">="
231
+ - - ">"
232
232
  - !ruby/object:Gem::Version
233
- version: '0'
233
+ version: 1.3.1
234
234
  requirements: []
235
235
  rubyforge_project:
236
236
  rubygems_version: 2.5.1