active_interaction-extras 1.0.1 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +2 -1
- data/active_interaction-extras.gemspec +8 -2
- data/lib/active_interaction/extras/halt.rb +5 -2
- data/lib/active_interaction/extras/model_fields.rb +7 -1
- data/lib/active_interaction/extras/strong_params.rb +1 -1
- data/lib/active_interaction/extras/transaction.rb +1 -0
- data/lib/active_interaction/extras/version.rb +1 -1
- metadata +75 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7c9ab1b398885ce07d041afd0698600f69ac5813434822945c5e1247e81e9a5
|
4
|
+
data.tar.gz: b8e73b105796596890f5518823c430c02e402c5d5aa4be353617b7bddae65182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f983de2973a1aae555f1576ec2eca88de323a714e8a0e778b2be96a15b29486cc0dfe0f03219ccb800b3354421c9dc138fd50324f992e7b415bd20b634360b54
|
7
|
+
data.tar.gz: 64b07f5287072bf90156987a0ec823b73341dc021e2b224c98f40dacbfa80240bd71b83d141323168a33e125fedb73d7547d7a919e0b3e4b7d603cd37743dc49
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,19 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [1.0.4] - 2022-06-08
|
8
|
+
|
9
|
+
- Improve halt's robustness (https://github.com/antulik/active_interaction-extras/pull/13)
|
10
|
+
|
11
|
+
## [1.0.3] - 2021-07-11
|
12
|
+
|
13
|
+
- Loosen the gem requirements
|
14
|
+
|
15
|
+
## [1.0.2] - 2021-07-07
|
16
|
+
|
17
|
+
- Requires active_interaction v4.0.2 or higher
|
18
|
+
- Fixed `run_in_transaction!` to rollback when interaction finished with errors
|
19
|
+
|
7
20
|
## [1.0.1] - 2021-05-13
|
8
21
|
|
9
22
|
- Fix `run_in_transaction` in ruby 3 [#8](https://github.com/antulik/active_interaction-extras/pull/8)
|
data/README.md
CHANGED
@@ -390,7 +390,8 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
390
390
|
|
391
391
|
## Credits
|
392
392
|
|
393
|
-
ActiveInteraction::Extras is brought to you by [Anton Katunin](https://github.com/antulik) and was originally built at [CarNextDoor](https://www.carnextdoor.com.au/).
|
393
|
+
* ActiveInteraction::Extras is brought to you by [Anton Katunin](https://github.com/antulik) and was originally built at [CarNextDoor](https://www.carnextdoor.com.au/).
|
394
|
+
* Further improvements to this gem brought to you by [Anton Katunin](https://github.com/antulik) once again and the [Split Payments team](https://github.com/splitpayments/split).
|
394
395
|
|
395
396
|
## Code of Conduct
|
396
397
|
|
@@ -24,10 +24,16 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
-
spec.add_dependency "active_interaction", ">= 4"
|
28
|
-
spec.add_dependency "
|
27
|
+
spec.add_dependency "active_interaction", ">= 4.0.2"
|
28
|
+
spec.add_dependency "activemodel", ">= 6.0"
|
29
|
+
spec.add_dependency "activesupport", ">= 6.0"
|
30
|
+
|
29
31
|
spec.add_development_dependency "bundler", "~> 2.2"
|
30
32
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
31
33
|
spec.add_development_dependency "rspec", "~> 3.7"
|
32
34
|
spec.add_development_dependency "pry"
|
35
|
+
spec.add_development_dependency "sqlite3"
|
36
|
+
spec.add_development_dependency "activerecord"
|
37
|
+
spec.add_development_dependency "activejob"
|
38
|
+
spec.add_development_dependency "actionpack"
|
33
39
|
end
|
@@ -1,16 +1,19 @@
|
|
1
1
|
module ActiveInteraction::Extras::Halt
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
+
THROW_OBJECT = Object.new.freeze
|
5
|
+
private_constant :THROW_OBJECT
|
6
|
+
|
4
7
|
included do
|
5
8
|
set_callback :execute, :around, lambda { |_interaction, block|
|
6
|
-
catch
|
9
|
+
catch THROW_OBJECT do
|
7
10
|
block.call
|
8
11
|
end
|
9
12
|
}
|
10
13
|
end
|
11
14
|
|
12
15
|
def halt!
|
13
|
-
throw
|
16
|
+
throw THROW_OBJECT, errors
|
14
17
|
end
|
15
18
|
|
16
19
|
def halt_if_errors!
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "active_support/core_ext/object/with_options"
|
2
|
+
|
1
3
|
module ActiveInteraction::Extras::ModelFields
|
2
4
|
extend ActiveSupport::Concern
|
3
5
|
|
@@ -46,6 +48,10 @@ module ActiveInteraction::Extras::ModelFields
|
|
46
48
|
alias file custom_filter_attribute
|
47
49
|
alias boolean custom_filter_attribute
|
48
50
|
alias array custom_filter_attribute
|
51
|
+
alias record custom_filter_attribute
|
52
|
+
|
53
|
+
alias anything custom_filter_attribute
|
54
|
+
alias uuid custom_filter_attribute
|
49
55
|
end
|
50
56
|
|
51
57
|
# checks if value was given to the service and the value is different from
|
@@ -64,7 +70,7 @@ module ActiveInteraction::Extras::ModelFields
|
|
64
70
|
end
|
65
71
|
|
66
72
|
# overwritten to pre-populate model fields
|
67
|
-
def
|
73
|
+
def populate_filters_and_inputs(_inputs)
|
68
74
|
super.tap do
|
69
75
|
self.class.filters.each do |name, filter|
|
70
76
|
next if given?(name)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ActiveInteraction::Extras::StrongParams
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
-
def
|
4
|
+
def initialize(inputs = {})
|
5
5
|
# TODO: whitelist :params and :form_params, so they could not be used as filters
|
6
6
|
return super if self.class.filters.key?(:params) || self.class.filters.key?(:form_params)
|
7
7
|
|
@@ -9,6 +9,7 @@ module ActiveInteraction::Extras::Transaction
|
|
9
9
|
set_callback :execute, :around, ->(_interaction, block) {
|
10
10
|
ActiveRecord::Base.transaction(**run_in_transaction_options) do
|
11
11
|
block.call
|
12
|
+
raise ActiveRecord::Rollback if _interaction.errors.any?
|
12
13
|
end
|
13
14
|
}, if: :run_in_transaction_options
|
14
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_interaction-extras
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Katunin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_interaction
|
@@ -16,16 +16,30 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: activemodel
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
@@ -94,6 +108,62 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: activerecord
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: activejob
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: actionpack
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
97
167
|
description: Extensions for active_interaction gem
|
98
168
|
email:
|
99
169
|
- antulik@gmail.com
|