activeinteractor 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +4 -5
- data/lib/active_interactor/config.rb +1 -1
- data/lib/active_interactor/context/attributes.rb +10 -0
- data/lib/active_interactor/interactor/perform.rb +5 -1
- data/lib/active_interactor/organizer/interactor_interface_collection.rb +1 -0
- data/lib/active_interactor/version.rb +1 -1
- data/spec/active_interactor/context/base_spec.rb +43 -0
- data/spec/spec_helper.rb +14 -13
- metadata +31 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 491bd06fcc2f9baf372f817dab6e40c69a07d5ff15721f5136815bcdeb04656b
|
4
|
+
data.tar.gz: 80e520f97369ab0f9465842eb31f9b0c0e638135cdc73ee27ded9cdc12272cf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3409d7c2a1c81fcfa6482493569a015356f6239635b4ea539947687c2e2ba44947825b8914ee264df7280e7f612184b35ae67cc10010a6df793087f249aacc81
|
7
|
+
data.tar.gz: dd892f0304bd572a8074c56cad88a231a9ca328b6365ffb96cf87ea7c60c5121f11ed32c3de70a550e3d9ea7fdeb5489667b653041e41c64e90dd661ea35d5e7
|
data/CHANGELOG.md
CHANGED
@@ -7,12 +7,17 @@ and this project adheres to [Semantic Versioning].
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [v1.0.5] - 2020-09-15
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
- [\#200](https://github.com/aaronmallen/activeinteractor/issues/200) Context attributes assigned in interactor not accessible as element within interactor
|
15
|
+
|
10
16
|
## [v1.0.4] - 2020-02-11
|
11
17
|
|
12
18
|
### Fixed
|
13
19
|
|
14
20
|
- [\#184](https://github.com/aaronmallen/activeinteractor/issues/184) `ActiveInteractor::Context::Base#fail!` error
|
15
|
-
message gets pupulated 3 times with the same message.
|
16
21
|
|
17
22
|
## [v1.0.3] - 2020-02-10
|
18
23
|
|
data/README.md
CHANGED
@@ -2,12 +2,11 @@
|
|
2
2
|
|
3
3
|
[![Version](https://img.shields.io/gem/v/activeinteractor.svg?logo=ruby)](https://rubygems.org/gems/activeinteractor)
|
4
4
|
[![Build Status](https://github.com/aaronmallen/activeinteractor/workflows/Build/badge.svg)](https://github.com/aaronmallen/activeinteractor/actions)
|
5
|
-
[![
|
6
|
-
[![Test Coverage](https://api.
|
7
|
-
[![Dependencies](https://img.shields.io/depfu/aaronmallen/activeinteractor.svg?maxAge=300)](https://depfu.com/github/aaronmallen/activeinteractor)
|
5
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/2f1cb318f681a1eebb27/maintainability)](https://codeclimate.com/github/aaronmallen/activeinteractor/maintainability)
|
6
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/2f1cb318f681a1eebb27/test_coverage)](https://codeclimate.com/github/aaronmallen/activeinteractor/test_coverage)
|
8
7
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/gems/activeinteractor)
|
9
|
-
[![Inline docs](http://inch-ci.org/github/aaronmallen/activeinteractor.svg?branch=
|
10
|
-
[![License](https://img.shields.io/github/license/aaronmallen/activeinteractor.svg?maxAge=300)](https://github.com/aaronmallen/activeinteractor/blob/
|
8
|
+
[![Inline docs](http://inch-ci.org/github/aaronmallen/activeinteractor.svg?branch=main)](http://inch-ci.org/github/aaronmallen/activeinteractor)
|
9
|
+
[![License](https://img.shields.io/github/license/aaronmallen/activeinteractor.svg?maxAge=300)](https://github.com/aaronmallen/activeinteractor/blob/main/LICENSE)
|
11
10
|
|
12
11
|
An implementation of the [command pattern] for Ruby with [ActiveModel::Validations] inspired by the
|
13
12
|
[interactor][collective_idea_interactors] gem. Rich support for attributes, callbacks, and validations,
|
@@ -59,6 +59,16 @@ module ActiveInteractor
|
|
59
59
|
merge_attribute_values(context)
|
60
60
|
end
|
61
61
|
|
62
|
+
# Returns the value of an attribute
|
63
|
+
#
|
64
|
+
# @since 1.0.5
|
65
|
+
#
|
66
|
+
# @param name [String, Symbol] the key of the value to be returned
|
67
|
+
# @returns [*] the attribute value
|
68
|
+
def [](name)
|
69
|
+
@table[name.to_sym] || attributes[name.to_sym]
|
70
|
+
end
|
71
|
+
|
62
72
|
# Get values defined on the instance of {Base context} whose keys are defined on the {Base context} class'
|
63
73
|
# {ClassMethods#attributes .attributes}
|
64
74
|
#
|
@@ -175,7 +175,11 @@ module ActiveInteractor
|
|
175
175
|
#
|
176
176
|
# @return [Base] a duplicated {Base interactor} instance
|
177
177
|
def deep_dup
|
178
|
-
|
178
|
+
dupped = dup
|
179
|
+
%w[@context @options].each do |variable|
|
180
|
+
dupped.instance_variable_set(variable, instance_variable_get(variable)&.dup)
|
181
|
+
end
|
182
|
+
dupped
|
179
183
|
end
|
180
184
|
|
181
185
|
# Options for the {Base interactor} {#perform}
|
@@ -14,6 +14,7 @@ module ActiveInteractor
|
|
14
14
|
# @return [Array<InteractorInterface>] the {InteractorInterface} collection
|
15
15
|
class InteractorInterfaceCollection
|
16
16
|
attr_reader :collection
|
17
|
+
|
17
18
|
# @!method map(&block)
|
18
19
|
# Invokes the given block once for each element of {#collection}.
|
19
20
|
# @return [Array] a new array containing the values returned by the block.
|
@@ -34,6 +34,49 @@ RSpec.describe ActiveInteractor::Context::Base do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
describe '#[]' do
|
38
|
+
subject { instance[attribute] }
|
39
|
+
|
40
|
+
context 'with class attributes []' do
|
41
|
+
let(:instance) { build_context.new }
|
42
|
+
|
43
|
+
context 'with attribute nil' do
|
44
|
+
let(:attribute) { :foo }
|
45
|
+
|
46
|
+
it { is_expected.to be_nil }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with attribute equal to "foo"' do
|
50
|
+
let(:attribute) { :foo }
|
51
|
+
before { instance.foo = 'foo' }
|
52
|
+
|
53
|
+
it { is_expected.to eq 'foo' }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'with class attributes [:foo]' do
|
58
|
+
let!(:context_class) do
|
59
|
+
build_context do
|
60
|
+
attributes :foo
|
61
|
+
end
|
62
|
+
end
|
63
|
+
let(:instance) { context_class.new }
|
64
|
+
|
65
|
+
context 'with attribute nil' do
|
66
|
+
let(:attribute) { :foo }
|
67
|
+
|
68
|
+
it { is_expected.to be_nil }
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'with attribute equal to "foo"' do
|
72
|
+
let(:attribute) { :foo }
|
73
|
+
before { instance.foo = 'foo' }
|
74
|
+
|
75
|
+
it { is_expected.to eq 'foo' }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
37
80
|
describe '#attribute?' do
|
38
81
|
subject { instance.attribute?(attribute) }
|
39
82
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
begin
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
4
|
+
require 'simplecov'
|
5
|
+
require 'simplecov-lcov'
|
6
|
+
|
7
|
+
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
8
|
+
|
9
|
+
SimpleCov.start do
|
10
|
+
enable_coverage :branch
|
11
|
+
add_filter '/spec/'
|
12
|
+
add_filter '/lib/rails/**/*.rb'
|
13
|
+
track_files '/lib/**/*.rb'
|
14
|
+
formatter SimpleCov::Formatter::MultiFormatter.new([
|
15
|
+
SimpleCov::Formatter::HTMLFormatter,
|
16
|
+
SimpleCov::Formatter::LcovFormatter
|
17
|
+
])
|
17
18
|
end
|
18
19
|
rescue LoadError
|
19
20
|
puts 'Skipping coverage...'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeinteractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -201,10 +201,10 @@ licenses:
|
|
201
201
|
- MIT
|
202
202
|
metadata:
|
203
203
|
bug_tracker_uri: https://github.com/aaronmallen/activeinteractor/issues
|
204
|
-
changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.0.
|
205
|
-
documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.0.
|
204
|
+
changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.0.5/CHANGELOG.md
|
205
|
+
documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.0.5
|
206
206
|
hompage_uri: https://github.com/aaronmallen/activeinteractor
|
207
|
-
source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.0.
|
207
|
+
source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.0.5
|
208
208
|
wiki_uri: https://github.com/aaronmallen/activeinteractor/wiki
|
209
209
|
post_install_message:
|
210
210
|
rdoc_options: []
|
@@ -226,41 +226,41 @@ signing_key:
|
|
226
226
|
specification_version: 4
|
227
227
|
summary: Ruby interactors with ActiveModel::Validations
|
228
228
|
test_files:
|
229
|
-
- spec/spec_helper.rb
|
230
|
-
- spec/support/helpers/factories.rb
|
231
|
-
- spec/support/spec_helpers.rb
|
232
|
-
- spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
|
233
|
-
- spec/support/shared_examples/a_class_with_interactor_methods_example.rb
|
234
229
|
- spec/support/shared_examples/a_class_that_extends_active_interactor_models_example.rb
|
230
|
+
- spec/support/shared_examples/a_class_with_interactor_methods_example.rb
|
231
|
+
- spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
|
235
232
|
- spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb
|
236
233
|
- spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb
|
237
|
-
- spec/
|
238
|
-
- spec/
|
239
|
-
- spec/
|
240
|
-
- spec/active_interactor/config_spec.rb
|
241
|
-
- spec/active_interactor/organizer/interactor_interface_collection_spec.rb
|
242
|
-
- spec/active_interactor/organizer/interactor_interface_spec.rb
|
243
|
-
- spec/active_interactor/organizer/base_spec.rb
|
244
|
-
- spec/active_interactor/base_spec.rb
|
245
|
-
- spec/active_interactor/context/base_spec.rb
|
246
|
-
- spec/integration/an_organizer_performing_in_parallel_spec.rb
|
234
|
+
- spec/support/spec_helpers.rb
|
235
|
+
- spec/support/helpers/factories.rb
|
236
|
+
- spec/integration/an_interactor_with_validations_on_calling_spec.rb
|
247
237
|
- spec/integration/a_basic_interactor_spec.rb
|
248
|
-
- spec/integration/
|
249
|
-
- spec/integration/a_failing_interactor_spec.rb
|
250
|
-
- spec/integration/an_interactor_with_before_perform_callbacks_spec.rb
|
238
|
+
- spec/integration/a_basic_organizer_spec.rb
|
251
239
|
- spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb
|
252
240
|
- spec/integration/an_interactor_with_validations_spec.rb
|
253
|
-
- spec/integration/
|
254
|
-
- spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb
|
241
|
+
- spec/integration/an_interactor_with_an_existing_context_class_spec.rb
|
255
242
|
- spec/integration/an_organizer_with_around_each_callbacks_spec.rb
|
243
|
+
- spec/integration/an_interactor_with_validations_on_called_spec.rb
|
244
|
+
- spec/integration/an_interactor_with_around_perform_callbacks_spec.rb
|
256
245
|
- spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb
|
257
|
-
- spec/integration/
|
258
|
-
- spec/integration/an_organizer_with_after_each_callbacks_spec.rb
|
259
|
-
- spec/integration/a_basic_organizer_spec.rb
|
260
|
-
- spec/integration/an_interactor_with_after_perform_callbacks_spec.rb
|
246
|
+
- spec/integration/an_interactor_with_before_perform_callbacks_spec.rb
|
261
247
|
- spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb
|
262
|
-
- spec/integration/
|
263
|
-
- spec/integration/an_interactor_with_validations_on_called_spec.rb
|
248
|
+
- spec/integration/an_interactor_with_after_perform_callbacks_spec.rb
|
264
249
|
- spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb
|
250
|
+
- spec/integration/an_organizer_with_after_each_callbacks_spec.rb
|
265
251
|
- spec/integration/active_record_integration_spec.rb
|
252
|
+
- spec/integration/a_failing_interactor_spec.rb
|
253
|
+
- spec/integration/an_organizer_with_before_each_callbacks_spec.rb
|
254
|
+
- spec/integration/an_organizer_performing_in_parallel_spec.rb
|
255
|
+
- spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb
|
256
|
+
- spec/active_interactor/interactor/worker_spec.rb
|
257
|
+
- spec/active_interactor/interactor/perform/options_spec.rb
|
258
|
+
- spec/active_interactor/context/base_spec.rb
|
259
|
+
- spec/active_interactor/config_spec.rb
|
260
|
+
- spec/active_interactor/error_spec.rb
|
261
|
+
- spec/active_interactor/base_spec.rb
|
262
|
+
- spec/active_interactor/organizer/interactor_interface_collection_spec.rb
|
263
|
+
- spec/active_interactor/organizer/base_spec.rb
|
264
|
+
- spec/active_interactor/organizer/interactor_interface_spec.rb
|
265
|
+
- spec/spec_helper.rb
|
266
266
|
- spec/active_interactor_spec.rb
|