active_interaction 4.0.3 → 4.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 +4 -4
- data/CHANGELOG.md +11 -2
- data/README.md +6 -11
- data/lib/active_interaction.rb +1 -0
- data/lib/active_interaction/filters/array_filter.rb +1 -1
- data/lib/active_interaction/filters/hash_filter.rb +1 -1
- data/lib/active_interaction/modules/validation.rb +6 -15
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/filters/array_filter_spec.rb +12 -0
- data/spec/active_interaction/integration/hash_interaction_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -6
- metadata +21 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24af31782cca3b666b2f211506cb3ca39e362ffcb665ae509bda892b13e65934
|
4
|
+
data.tar.gz: 3a139e271e9d19ac23cdea62a5bbe882889f50483647951289623b8f3aaaf97f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 574d84a7a67526dcb2b7f64ca885d6cccb3115612e731b4091bd1bb122446a88ce81ad791196c6bd33555122e9b2c8b07ac1924cecbe400f4d541906274fcd3c
|
7
|
+
data.tar.gz: 1260eae401d19342ef4b8e2ada334553e7b99672b3257ec9b5880d0c6566eb8dc86e8de9fc5c5a3d0ed37485f86fc88cdb3adc2abe6299ac60d049f1d0713474
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [4.0.4][] (2021-07-03)
|
2
|
+
|
3
|
+
## Fix
|
4
|
+
|
5
|
+
- [#510][] - Hash parameters failed when working outside of Rails.
|
6
|
+
- [#511][] - Nested filters with options but no `:class` failed to have `:class` automatically added.
|
7
|
+
|
1
8
|
# [4.0.3][] (2021-06-24)
|
2
9
|
|
3
10
|
## Fix
|
@@ -77,7 +84,7 @@ class Example < ActiveInteraction::Base
|
|
77
84
|
|
78
85
|
validates :first_name,
|
79
86
|
presence: true,
|
80
|
-
unless:
|
87
|
+
unless: -> { first_name.nil? }
|
81
88
|
|
82
89
|
def execute
|
83
90
|
# ...
|
@@ -951,7 +958,8 @@ Example.run
|
|
951
958
|
|
952
959
|
- Initial release.
|
953
960
|
|
954
|
-
[4.0.
|
961
|
+
[4.0.4]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.3...v4.0.4
|
962
|
+
[4.0.3]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.2...v4.0.3
|
955
963
|
[4.0.2]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.1...v4.0.2
|
956
964
|
[4.0.1]: https://github.com/AaronLasseigne/active_interaction/compare/v4.0.0...v4.0.1
|
957
965
|
[4.0.0]: https://github.com/AaronLasseigne/active_interaction/compare/v3.8.3...v4.0.0
|
@@ -1163,3 +1171,4 @@ Example.run
|
|
1163
1171
|
[#505]: https://github.com/AaronLasseigne/active_interaction/issues/505
|
1164
1172
|
[#499]: https://github.com/AaronLasseigne/active_interaction/issues/499
|
1165
1173
|
[#493]: https://github.com/AaronLasseigne/active_interaction/issues/493
|
1174
|
+
[#510]: https://github.com/AaronLasseigne/active_interaction/issues/510
|
data/README.md
CHANGED
@@ -5,7 +5,6 @@ It's an implementation of the command pattern in Ruby.
|
|
5
5
|
|
6
6
|
[](https://rubygems.org/gems/active_interaction)
|
7
7
|
[](https://github.com/AaronLasseigne/active_interaction/actions?query=workflow%3ATest)
|
8
|
-
[](https://coveralls.io/r/orgsync/active_interaction)
|
9
8
|
[](https://codeclimate.com/github/orgsync/active_interaction)
|
10
9
|
|
11
10
|
---
|
@@ -58,7 +57,7 @@ handles your verbs.
|
|
58
57
|
- [Translations](#translations)
|
59
58
|
- [Credits](#credits)
|
60
59
|
|
61
|
-
[
|
60
|
+
[API Documentation][]
|
62
61
|
|
63
62
|
## Installation
|
64
63
|
|
@@ -977,10 +976,10 @@ class UpdateAccount < ActiveInteraction::Base
|
|
977
976
|
|
978
977
|
validates :first_name,
|
979
978
|
presence: true,
|
980
|
-
unless:
|
979
|
+
unless: -> { first_name.nil? }
|
981
980
|
validates :last_name,
|
982
981
|
presence: true,
|
983
|
-
unless:
|
982
|
+
unless: -> { last_name.nil? }
|
984
983
|
|
985
984
|
def execute
|
986
985
|
account.first_name = first_name if first_name.present?
|
@@ -1448,8 +1447,8 @@ I18nInteraction.run(name: false).errors.messages[:name]
|
|
1448
1447
|
|
1449
1448
|
## Credits
|
1450
1449
|
|
1451
|
-
ActiveInteraction is brought to you by [Aaron Lasseigne][]
|
1452
|
-
[Taylor Fausak][] and
|
1450
|
+
ActiveInteraction is brought to you by [Aaron Lasseigne][].
|
1451
|
+
Along with Aaron, [Taylor Fausak][] helped create and maintain ActiveInteraction but has since moved on.
|
1453
1452
|
|
1454
1453
|
If you want to contribute to ActiveInteraction, please read
|
1455
1454
|
[our contribution guidelines][]. A [complete list of contributors][] is
|
@@ -1458,14 +1457,11 @@ available on GitHub.
|
|
1458
1457
|
ActiveInteraction is licensed under [the MIT License][].
|
1459
1458
|
|
1460
1459
|
[activeinteraction]: https://github.com/AaronLasseigne/active_interaction
|
1461
|
-
[
|
1460
|
+
[API Documentation]: http://rubydoc.info/github/AaronLasseigne/active_interaction
|
1462
1461
|
[semantic versioning]: http://semver.org/spec/v2.0.0.html
|
1463
1462
|
[GitHub releases]: https://github.com/AaronLasseigne/active_interaction/releases
|
1464
|
-
[the announcement post]: http://devblog.orgsync.com/2015/05/06/announcing-active-interaction-2/
|
1465
|
-
[active_model-errors_details]: https://github.com/cowbell/active_model-errors_details
|
1466
1463
|
[aaron lasseigne]: https://github.com/AaronLasseigne
|
1467
1464
|
[taylor fausak]: https://github.com/tfausak
|
1468
|
-
[orgsync]: https://github.com/orgsync
|
1469
1465
|
[our contribution guidelines]: CONTRIBUTING.md
|
1470
1466
|
[complete list of contributors]: https://github.com/AaronLasseigne/active_interaction/graphs/contributors
|
1471
1467
|
[the mit license]: LICENSE.md
|
@@ -1474,5 +1470,4 @@ ActiveInteraction is licensed under [the MIT License][].
|
|
1474
1470
|
[the filters section]: #filters
|
1475
1471
|
[the errors section]: #errors
|
1476
1472
|
[the optional inputs section]: #optional-inputs
|
1477
|
-
[aire]: example
|
1478
1473
|
[`with_options`]: http://api.rubyonrails.org/classes/Object.html#method-i-with_options
|
data/lib/active_interaction.rb
CHANGED
@@ -73,7 +73,7 @@ module ActiveInteraction
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def add_option_in_place_of_name(klass, options)
|
76
|
-
if (keys = FILTER_NAME_OR_OPTION[klass.to_s]) && (keys
|
76
|
+
if (keys = FILTER_NAME_OR_OPTION[klass.to_s]) && (keys & options.keys).empty?
|
77
77
|
options.merge(
|
78
78
|
"#{keys.first}": name.to_s.singularize.camelize.to_sym
|
79
79
|
)
|
@@ -44,7 +44,7 @@ module ActiveInteraction
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def adjust_output(value, context)
|
47
|
-
value = value.to_hash
|
47
|
+
value = ActiveSupport::HashWithIndifferentAccess.new(value.to_hash)
|
48
48
|
|
49
49
|
initial = strip? ? ActiveSupport::HashWithIndifferentAccess.new : value
|
50
50
|
|
@@ -14,26 +14,17 @@ module ActiveInteraction
|
|
14
14
|
filter.clean(inputs[name], context)
|
15
15
|
rescue NoDefaultError
|
16
16
|
nil
|
17
|
-
rescue InvalidNestedValueError
|
18
|
-
|
19
|
-
|
20
|
-
errors <<
|
17
|
+
rescue InvalidNestedValueError => e
|
18
|
+
errors << [filter.name, :invalid_nested, { name: e.filter_name.inspect, value: e.input_value.inspect }]
|
19
|
+
rescue InvalidValueError
|
20
|
+
errors << [filter.name, :invalid_type, { type: type(filter) }]
|
21
|
+
rescue MissingValueError
|
22
|
+
errors << [filter.name, :missing]
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
|
-
def error_args(filter, error)
|
27
|
-
case error
|
28
|
-
when InvalidNestedValueError
|
29
|
-
[filter.name, :invalid_nested, { name: error.filter_name.inspect, value: error.input_value.inspect }]
|
30
|
-
when InvalidValueError
|
31
|
-
[filter.name, :invalid_type, { type: type(filter) }]
|
32
|
-
when MissingValueError
|
33
|
-
[filter.name, :missing]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
28
|
# @param filter [Filter]
|
38
29
|
def type(filter)
|
39
30
|
I18n.translate("#{Base.i18n_scope}.types.#{filter.class.slug}")
|
@@ -137,6 +137,18 @@ describe ActiveInteraction::ArrayFilter, :filter do
|
|
137
137
|
expect(filter.filters[:'0'].options[:methods]).to eql %i[to_s]
|
138
138
|
end
|
139
139
|
end
|
140
|
+
|
141
|
+
context 'with another option set' do
|
142
|
+
let(:block) { proc { public_send(:object, converter: :new) } }
|
143
|
+
let(:name) { :objects }
|
144
|
+
|
145
|
+
it 'has a filter with the right options' do
|
146
|
+
expect(filter.filters[:'0'].options).to have_key(:class)
|
147
|
+
expect(filter.filters[:'0'].options[:class]).to eql :Object
|
148
|
+
expect(filter.filters[:'0'].options).to have_key(:converter)
|
149
|
+
expect(filter.filters[:'0'].options[:converter]).to eql :new
|
150
|
+
end
|
151
|
+
end
|
140
152
|
end
|
141
153
|
end
|
142
154
|
|
@@ -19,7 +19,7 @@ describe HashInteraction do
|
|
19
19
|
before { inputs[:a] = a }
|
20
20
|
|
21
21
|
it 'returns the correct value for :a' do
|
22
|
-
expect(result[:a]).to eql a
|
22
|
+
expect(result[:a]).to eql ActiveSupport::HashWithIndifferentAccess.new(a)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'returns the correct value for :b' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,3 @@
|
|
1
|
-
# Disable code coverage for JRuby because it always reports 0% coverage.
|
2
|
-
if RUBY_ENGINE != 'jruby'
|
3
|
-
require 'coveralls'
|
4
|
-
Coveralls.wear!
|
5
|
-
end
|
6
|
-
|
7
1
|
require 'i18n'
|
8
2
|
I18n.config.enforce_available_locales = true if I18n.config.respond_to?(:enforce_available_locales)
|
9
3
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_interaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Lasseigne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-07-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -32,21 +32,27 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '7'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
|
-
name:
|
35
|
+
name: activesupport
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
|
40
|
+
version: '5'
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '7'
|
44
|
+
type: :runtime
|
42
45
|
prerelease: false
|
43
46
|
version_requirements: !ruby/object:Gem::Requirement
|
44
47
|
requirements:
|
45
48
|
- - ">="
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
50
|
+
version: '5'
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '7'
|
48
54
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
55
|
+
name: actionpack
|
50
56
|
requirement: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - ">="
|
@@ -60,33 +66,33 @@ dependencies:
|
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '0'
|
62
68
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
69
|
+
name: activerecord
|
64
70
|
requirement: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- - "
|
72
|
+
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
74
|
+
version: '0'
|
69
75
|
type: :development
|
70
76
|
prerelease: false
|
71
77
|
version_requirements: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
|
-
- - "
|
79
|
+
- - ">="
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
81
|
+
version: '0'
|
76
82
|
- !ruby/object:Gem::Dependency
|
77
|
-
name:
|
83
|
+
name: benchmark-ips
|
78
84
|
requirement: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
88
|
+
version: '2.7'
|
83
89
|
type: :development
|
84
90
|
prerelease: false
|
85
91
|
version_requirements: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
93
|
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
95
|
+
version: '2.7'
|
90
96
|
- !ruby/object:Gem::Dependency
|
91
97
|
name: kramdown
|
92
98
|
requirement: !ruby/object:Gem::Requirement
|