rdux 1.0.0 β†’ 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -4
  3. data/lib/rdux/version.rb +1 -1
  4. data/lib/rdux.rb +7 -5
  5. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8afda82ad3e063c5a07eb7c3e8b2a9f86019bb35ccdaa8fc875a9aebcd463a29
4
- data.tar.gz: 2d72f680e8cb5014fb55b003b09ea11cbf23107e54c8e83e2e0b5e7bff44b860
3
+ metadata.gz: d9466995069583a72d2327967aebfa05218c2c224aa091645dbee874e53a491f
4
+ data.tar.gz: e1ec237a0de458512951e68f29596b0677a45d56b417d4b139ee4aa6a79bea13
5
5
  SHA512:
6
- metadata.gz: 982c68f70df4e2c579e88029551a969f54470c0fa328ce5d1cbf89007001ac93fc6f78aec1a2e0096081c852174265c2e3412714d8466b7eb6ee9073273e3d3a
7
- data.tar.gz: 3e63ef96279b424c87f34a23292c70b3cc95d390b63d7f92d83ad1faf95df34b9f18ada2f969a18bf79bb6846da543f5d6b437322453844ea63fbbe21ba13129
6
+ metadata.gz: f1eec1d56443a217a827f9cfc6d30bbcc0d0ab4fb68dc912cbf9ac4986342e91de660e4876ce7d3bbf67493905be10edd5b2a07fa2056d110fe118f2f5e68892
7
+ data.tar.gz: 799a77dd6396597790ca62b27cc203fa4b529935a486d6136645bc64d8759801b844c918f863e990a1e06cd973c4b02184da100d496a1439a3c957c34f4a3581
data/README.md CHANGED
@@ -17,7 +17,7 @@ Rdux is a lightweight, minimalistic Rails plugin designed to introduce event sou
17
17
 
18
18
  * **Audit Logging** πŸ‘‰ Rdux stores sanitized input data, the name of module or class (action performer) responsible for processing them, processing results, and additional metadata in the database.
19
19
  * **Model Representation** πŸ‘‰ Before action is executed it gets stored in the database through the `Rdux::Action` model. This model can be nested, allowing for complex action structures.
20
- * **Exception Handling and Recovery** πŸ‘‰ Rdux automatically creates a `Rdux::Action` record when an exception occurs during action execution. It retains the `payload` and allows you to capture additional data using `opts[:result]`, ensuring all necessary information is available for retrying the action.
20
+ * **Exception Handling and Recovery** πŸ‘‰ Rdux automatically creates a `Rdux::Action` record when an exception occurs during action execution. It retains the `payload` and allows you to capture additional data using `opts[:action].result`, ensuring all necessary information is available for retrying the action.
21
21
  * **Metadata** πŸ‘‰ Metadata can include the ID of the authenticated resource responsible for performing a given action, as well as resource IDs from external systems related to the action. This creates a clear audit trail of who executed each action and on whose behalf.
22
22
 
23
23
  Rdux is designed to integrate seamlessly with your existing Rails application, offering a straightforward and powerful solution for managing and auditing key actions.
@@ -244,8 +244,7 @@ end
244
244
  Rdux captures exceptions raised during the execution of an action and sets the `Rdux::Action#ok` attribute to `false`.
245
245
  The `payload` is retained, but having only the input data is often not enough to retry an action.
246
246
  It is crucial to capture data obtained during the action’s execution, up until the exception occurred.
247
- This can be done by using `opts[:result]` to store all necessary data incrementally.
248
- The assigned data will then be available as the `Rdux::Action#result` attribute.
247
+ This can be done by using `opts[:action].result` attribute to store all necessary data incrementally.
249
248
 
250
249
  Example:
251
250
 
@@ -257,7 +256,7 @@ class CreditCard
257
256
  create_res = create(payload.slice('user_id', 'credit_card'), opts.slice(:user))
258
257
  return create_res unless create_res.ok
259
258
 
260
- opts[:result] = { credit_card_create_action_id: create_res.action.id }
259
+ opts[:action].result = { credit_card_create_action_id: create_res.action.id }
261
260
  charge_id = PaymentGateway.charge(create_res.val[:credit_card].token, payload['amount'])[:id]
262
261
  if charge_id.nil?
263
262
  Rdux::Result[ok: false, val: { errors: { base: 'Invalid credit card' } }, save: true,
data/lib/rdux/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rdux
4
- VERSION = '1.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
data/lib/rdux.rb CHANGED
@@ -19,14 +19,13 @@ module Rdux
19
19
 
20
20
  def process(action, opts = {})
21
21
  res = action.call(opts)
22
- res.result ||= opts[:result]
23
22
  return res if destroy_action(res, action)
24
23
 
25
24
  assign_to_action(res, action)
26
25
  persist(res, action)
27
26
  res
28
27
  rescue StandardError => e
29
- handle_exception(e, action, opts[:result])
28
+ handle_exception(e, action)
30
29
  end
31
30
 
32
31
  alias perform dispatch
@@ -41,7 +40,10 @@ module Rdux
41
40
 
42
41
  def assign_to_action(res, action)
43
42
  action.ok = res.ok
44
- action.result = res.result
43
+ return unless res.result
44
+
45
+ action.result ||= {}
46
+ action.result.merge!(res.result)
45
47
  end
46
48
 
47
49
  def persist(res, action)
@@ -49,9 +51,9 @@ module Rdux
49
51
  res.nested&.each { |nested_res| action.rdux_actions << nested_res.action }
50
52
  end
51
53
 
52
- def handle_exception(exc, action, result)
54
+ def handle_exception(exc, action)
53
55
  action.ok = false
54
- action.result ||= result || {}
56
+ action.result ||= {}
55
57
  action.result.merge!({ 'Exception' => {
56
58
  class: exc.class.name,
57
59
  message: exc.message
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdux
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zbigniew Humeniuk
@@ -35,56 +35,56 @@ dependencies:
35
35
  requirements:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
38
- version: 1.5.9
38
+ version: 1.6.2
39
39
  type: :development
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 1.5.9
45
+ version: 1.6.2
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rubocop
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 1.66.1
52
+ version: 1.80.2
53
53
  type: :development
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.66.1
59
+ version: 1.80.2
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rubocop-rails
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: 2.26.0
66
+ version: 2.33.3
67
67
  type: :development
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 2.26.0
73
+ version: 2.33.3
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: sqlite3
76
76
  requirement: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
- version: 2.1.0
80
+ version: 2.7.4
81
81
  type: :development
82
82
  prerelease: false
83
83
  version_requirements: !ruby/object:Gem::Requirement
84
84
  requirements:
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
- version: 2.1.0
87
+ version: 2.7.4
88
88
  description: "Rdux is a lightweight, minimalistic Rails plugin designed to introduce
89
89
  event sourcing and audit logging capabilities to your Rails application. \nWith
90
90
  Rdux, you can efficiently track and store the history of actions performed within
@@ -105,7 +105,7 @@ files:
105
105
  - lib/rdux/result.rb
106
106
  - lib/rdux/store.rb
107
107
  - lib/rdux/version.rb
108
- homepage: https://artofcode.co
108
+ homepage: https://github.com/artofcodelabs/rdux
109
109
  licenses:
110
110
  - MIT
111
111
  metadata: