active_interaction 3.5.0 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_interaction/base.rb +1 -4
- data/lib/active_interaction/errors.rb +0 -7
- data/lib/active_interaction/modules/input_processor.rb +3 -3
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/base_spec.rb +3 -12
- data/spec/active_interaction/modules/input_processor_spec.rb +2 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efaabefa03827c037549d3199559e79028e01014
|
4
|
+
data.tar.gz: c31b3dfde06e95dd679771e2719300c3ceeb155a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e89ce8aa7c3d8ffa79de7720444086a425edc0e287ac0a87d96b5b987bc5275af0c916eef480f59f66b57b0be6c29a0b2c094bb0719de5156d0acb6a7b005bd5
|
7
|
+
data.tar.gz: cc04bc1579b22405deba56144038f681bbb99b3db413382bc5126a703a761e711fafbc23fb32dca99271472492619dd58ffec5f1b8628e28c71b8a16ac8f4415
|
@@ -2,7 +2,6 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require 'active_support/core_ext/hash/indifferent_access'
|
5
|
-
require 'set'
|
6
5
|
|
7
6
|
module ActiveInteraction
|
8
7
|
# @abstract Subclass and override {#execute} to implement a custom
|
@@ -277,9 +276,7 @@ module ActiveInteraction
|
|
277
276
|
@_interaction_inputs = inputs
|
278
277
|
|
279
278
|
inputs.each do |key, value|
|
280
|
-
|
281
|
-
|
282
|
-
populate_reader(key, value)
|
279
|
+
populate_reader(key, value) unless InputProcessor.reserved?(key)
|
283
280
|
end
|
284
281
|
|
285
282
|
populate_filters(InputProcessor.process(inputs))
|
@@ -48,13 +48,6 @@ module ActiveInteraction
|
|
48
48
|
# @return [Class]
|
49
49
|
NoDefaultError = Class.new(Error)
|
50
50
|
|
51
|
-
# Raised if a reserved name is used.
|
52
|
-
#
|
53
|
-
# @return [Class]
|
54
|
-
#
|
55
|
-
# @since 1.2.0
|
56
|
-
ReservedNameError = Class.new(Error)
|
57
|
-
|
58
51
|
# Raised if a user-supplied value to a nested hash input is invalid.
|
59
52
|
#
|
60
53
|
# @return [Class]
|
@@ -14,13 +14,13 @@ module ActiveInteraction
|
|
14
14
|
|
15
15
|
def reserved?(name)
|
16
16
|
name.to_s.start_with?('_interaction_') ||
|
17
|
-
Base.
|
18
|
-
Base.
|
17
|
+
Base.method_defined?(name) ||
|
18
|
+
Base.private_method_defined?(name)
|
19
19
|
end
|
20
20
|
|
21
21
|
def process(inputs)
|
22
22
|
inputs.stringify_keys.sort.each_with_object({}) do |(k, v), h|
|
23
|
-
|
23
|
+
next if reserved?(k)
|
24
24
|
|
25
25
|
if (match = GROUPED_INPUT_PATTERN.match(k))
|
26
26
|
assign_to_group!(h, *match.captures, v)
|
@@ -35,20 +35,11 @@ describe ActiveInteraction::Base do
|
|
35
35
|
subject(:interaction) { described_class.new(inputs) }
|
36
36
|
|
37
37
|
describe '.new(inputs = {})' do
|
38
|
-
it 'does not
|
39
|
-
key = :
|
38
|
+
it 'does not set instance vars for reserved input names' do
|
39
|
+
key = :execute
|
40
40
|
inputs[key] = nil
|
41
|
-
expect do
|
42
|
-
interaction
|
43
|
-
end.to raise_error ActiveInteraction::InvalidValueError
|
44
|
-
end
|
45
41
|
|
46
|
-
|
47
|
-
key = "_interaction_#{SecureRandom.hex}"
|
48
|
-
inputs[key] = nil
|
49
|
-
expect do
|
50
|
-
interaction
|
51
|
-
end.to raise_error ActiveInteraction::InvalidValueError
|
42
|
+
expect(interaction.instance_variable_defined?(:"@#{key}")).to be false
|
52
43
|
end
|
53
44
|
|
54
45
|
context 'with invalid inputs' do
|
@@ -74,10 +74,8 @@ describe ActiveInteraction::InputProcessor do
|
|
74
74
|
context 'with a reserved name' do
|
75
75
|
before { inputs[:_interaction_key] = :value }
|
76
76
|
|
77
|
-
it '
|
78
|
-
expect
|
79
|
-
result
|
80
|
-
end.to raise_error ActiveInteraction::ReservedNameError
|
77
|
+
it 'skips the input' do
|
78
|
+
expect(result).to_not have_key(:_interaction_key)
|
81
79
|
end
|
82
80
|
end
|
83
81
|
end
|
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: 3.5.
|
4
|
+
version: 3.5.1
|
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: 2017-
|
12
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
version: '0'
|
274
274
|
requirements: []
|
275
275
|
rubyforge_project:
|
276
|
-
rubygems_version: 2.6.
|
276
|
+
rubygems_version: 2.6.11
|
277
277
|
signing_key:
|
278
278
|
specification_version: 4
|
279
279
|
summary: Manage application specific business logic.
|