active_interaction-extras 1.0.1 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a71a37d918c487996272cfff3fab64da2241f0f071a659ff5f9cac97f76bf869
4
- data.tar.gz: 15bc8f3f20329df47325103a6c5971848d0c5c22eca399a0be2e28ba0c6abc52
3
+ metadata.gz: e7c9ab1b398885ce07d041afd0698600f69ac5813434822945c5e1247e81e9a5
4
+ data.tar.gz: b8e73b105796596890f5518823c430c02e402c5d5aa4be353617b7bddae65182
5
5
  SHA512:
6
- metadata.gz: 940a9e9195a01433b060227d3ff02450ac2b620972cf493f3760f9977b5106c071241aef5b5d9c1cef35d39937cfdae8efc2d81c508f4f68b6fe6d5b8ac5cd44
7
- data.tar.gz: d4358a521172fbca3c27be32b41bd5ba4c9cb0df79a5f1b3a2d5539b39f7d04ea5ee73a2abaeab5585529c71701821db2de599a253aaa7ce0ee93f1d808381b4
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 "rails", ">= 6.0"
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 :strict_error do
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 :strict_error, errors
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 populate_filters(_inputs)
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 process_inputs(inputs)
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
@@ -1,5 +1,5 @@
1
1
  module ActiveInteraction
2
2
  module Extras
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.4"
4
4
  end
5
5
  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.1
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: 2021-05-13 00:00:00.000000000 Z
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: '4'
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: '4'
26
+ version: 4.0.2
27
27
  - !ruby/object:Gem::Dependency
28
- name: rails
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