rdux 0.11.0 → 0.13.0
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.
- checksums.yaml +4 -4
- data/lib/rdux/version.rb +1 -1
- data/lib/rdux.rb +12 -7
- metadata +9 -13
- data/lib/rdux/sanitize.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a4732501f420e77c07dc015b11abfbd2f8c1985229772a2665cde14a99f2752
|
4
|
+
data.tar.gz: 7f35b68fa9a573ac225ad2f1aeea19139b56ee9d4a56d2618d638c2cf0cda820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b067094df508e07f8165ec5e88c094ec4c6f54bec1ddba8206ecd0bf74b2c6b1f3706c97f1ca56c8b622c68d30c20c272d993da40ce604dfb3cccfaa43084fca
|
7
|
+
data.tar.gz: 1b72e8f3b2d4cebb015957c996cee3ad10a428d7d23551ae56ccb5daf70b74f6ce556e36968a851e17fea51bb78e4ac55307f2e86c92d5376be38bb91c54d400
|
data/lib/rdux/version.rb
CHANGED
data/lib/rdux.rb
CHANGED
@@ -2,20 +2,16 @@
|
|
2
2
|
|
3
3
|
require 'rdux/engine'
|
4
4
|
require 'rdux/result'
|
5
|
-
require 'rdux/sanitize'
|
6
5
|
require 'active_support/concern'
|
7
6
|
|
8
7
|
module Rdux
|
9
8
|
class << self
|
10
9
|
def dispatch(action_name, payload, opts = {}, meta: nil)
|
11
|
-
|
12
|
-
action = Action.new(name: action_name, up_payload: payload, meta:)
|
13
|
-
sanitize(action)
|
14
|
-
action.save!
|
10
|
+
action = create_action(action_name, payload, opts, meta)
|
15
11
|
res = call_call_or_up_on_action(action, opts)
|
16
12
|
res.up_result ||= opts[:up_result]
|
17
13
|
assign_and_persist(res, action)
|
18
|
-
res.after_save
|
14
|
+
res.after_save.call(res.action) if res.after_save && res.action
|
19
15
|
res
|
20
16
|
end
|
21
17
|
|
@@ -23,6 +19,14 @@ module Rdux
|
|
23
19
|
|
24
20
|
private
|
25
21
|
|
22
|
+
def create_action(action_name, payload, opts, meta)
|
23
|
+
(opts[:ars] || {}).each { |k, v| payload["#{k}_id"] = v.id }
|
24
|
+
action = Action.new(name: action_name, up_payload: payload, meta:)
|
25
|
+
sanitize(action)
|
26
|
+
action.save!
|
27
|
+
action
|
28
|
+
end
|
29
|
+
|
26
30
|
def call_call_or_up_on_action(action, opts)
|
27
31
|
res = action.call(opts)
|
28
32
|
if res
|
@@ -75,7 +79,8 @@ module Rdux
|
|
75
79
|
end
|
76
80
|
|
77
81
|
def sanitize(action)
|
78
|
-
|
82
|
+
param_filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
|
83
|
+
up_payload_sanitized = param_filter.filter(action.up_payload)
|
79
84
|
action.up_payload_sanitized = action.up_payload != up_payload_sanitized
|
80
85
|
action.up_payload_unsanitized = action.up_payload if action.up_payload_sanitized
|
81
86
|
action.up_payload = up_payload_sanitized
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zbigniew Humeniuk
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -16,34 +15,34 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
18
|
+
version: '7.0'
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
21
|
+
version: '9.0'
|
23
22
|
type: :runtime
|
24
23
|
prerelease: false
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
28
|
+
version: '7.0'
|
30
29
|
- - "<"
|
31
30
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
31
|
+
version: '9.0'
|
33
32
|
- !ruby/object:Gem::Dependency
|
34
33
|
name: pg
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
36
35
|
requirements:
|
37
36
|
- - ">="
|
38
37
|
- !ruby/object:Gem::Version
|
39
|
-
version: 1.5.
|
38
|
+
version: 1.5.9
|
40
39
|
type: :development
|
41
40
|
prerelease: false
|
42
41
|
version_requirements: !ruby/object:Gem::Requirement
|
43
42
|
requirements:
|
44
43
|
- - ">="
|
45
44
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.5.
|
45
|
+
version: 1.5.9
|
47
46
|
- !ruby/object:Gem::Dependency
|
48
47
|
name: rubocop
|
49
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,14 +106,12 @@ files:
|
|
107
106
|
- lib/rdux.rb
|
108
107
|
- lib/rdux/engine.rb
|
109
108
|
- lib/rdux/result.rb
|
110
|
-
- lib/rdux/sanitize.rb
|
111
109
|
- lib/rdux/version.rb
|
112
110
|
homepage: https://artofcode.co
|
113
111
|
licenses:
|
114
112
|
- MIT
|
115
113
|
metadata:
|
116
114
|
rubygems_mfa_required: 'true'
|
117
|
-
post_install_message:
|
118
115
|
rdoc_options: []
|
119
116
|
require_paths:
|
120
117
|
- lib
|
@@ -129,8 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
126
|
- !ruby/object:Gem::Version
|
130
127
|
version: '0'
|
131
128
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
133
|
-
signing_key:
|
129
|
+
rubygems_version: 3.6.8
|
134
130
|
specification_version: 4
|
135
131
|
summary: A Minimal Event Sourcing Plugin for Rails
|
136
132
|
test_files: []
|
data/lib/rdux/sanitize.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Rdux
|
4
|
-
module Sanitize
|
5
|
-
class << self
|
6
|
-
def call(payload)
|
7
|
-
filtered_payload = payload.deep_dup # Create a duplicate to avoid modifying the original params
|
8
|
-
Rails.application.config.filter_parameters.each do |filter_param|
|
9
|
-
filter_recursive(filtered_payload, filter_param)
|
10
|
-
end
|
11
|
-
filtered_payload
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def filter_recursive(payload, filter_param)
|
17
|
-
payload.each do |key, value|
|
18
|
-
if value.is_a? Hash # If the value is a nested parameter
|
19
|
-
filter_recursive(value, filter_param)
|
20
|
-
elsif key == filter_param.to_s # to_s is used to ensure that symbol/string difference does not matter
|
21
|
-
payload[key] = '[FILTERED]'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|