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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27a9224897436b0f0c13ca2f34c728f26309d19580cab050b23460cfe2aa8b9e
4
- data.tar.gz: 4ca49b278929696a601f551f393641b107773d9cc30780954a49f4cd02193f35
3
+ metadata.gz: 491bd06fcc2f9baf372f817dab6e40c69a07d5ff15721f5136815bcdeb04656b
4
+ data.tar.gz: 80e520f97369ab0f9465842eb31f9b0c0e638135cdc73ee27ded9cdc12272cf1
5
5
  SHA512:
6
- metadata.gz: c51d11ddd7bc484646e7e7aae24f136ce257b7d377b2d70e3a6da1dbeacffaa6bf4dfbd6d96ee7fc2be7ab5709ed44e02ad5278ba6ad91524c34b4e941407f8c
7
- data.tar.gz: 2b2ef09ee580e8cfb64af433753ffe1ae694dcc54cf01e9b345930a7b16a429117964d3e11bc3a9747e67c1cdfd979820bd5376490f8f2201e21e72a00fce863
6
+ metadata.gz: 3409d7c2a1c81fcfa6482493569a015356f6239635b4ea539947687c2e2ba44947825b8914ee264df7280e7f612184b35ae67cc10010a6df793087f249aacc81
7
+ data.tar.gz: dd892f0304bd572a8074c56cad88a231a9ca328b6365ffb96cf87ea7c60c5121f11ed32c3de70a550e3d9ea7fdeb5489667b653041e41c64e90dd661ea35d5e7
@@ -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
- [![Code Quality](https://api.codacy.com/project/badge/Grade/be92c4ecf12347da82d266f6a4368b6e)](https://www.codacy.com/manual/aaronmallen/activeinteractor?utm_source=github.com&utm_medium=referral&utm_content=aaronmallen/activeinteractor&utm_campaign=Badge_Grade)
6
- [![Test Coverage](https://api.codacy.com/project/badge/Coverage/be92c4ecf12347da82d266f6a4368b6e)](https://www.codacy.com/manual/aaronmallen/activeinteractor?utm_source=github.com&utm_medium=referral&utm_content=aaronmallen/activeinteractor&utm_campaign=Badge_Coverage)
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=master)](http://inch-ci.org/github/aaronmallen/activeinteractor)
10
- [![License](https://img.shields.io/github/license/aaronmallen/activeinteractor.svg?maxAge=300)](https://github.com/aaronmallen/activeinteractor/blob/master/LICENSE)
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,
@@ -23,7 +23,7 @@ module ActiveInteractor
23
23
  # @return [Config] a new instance of {Config}
24
24
  class Config
25
25
  include ActiveInteractor::Configurable
26
- defaults logger: Logger.new(STDOUT)
26
+ defaults logger: Logger.new($stdout)
27
27
  end
28
28
 
29
29
  # The ActiveInteractor configuration
@@ -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
- self.class.new(context.dup).with_options(options.dup)
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.
@@ -3,5 +3,5 @@
3
3
  module ActiveInteractor
4
4
  # The ActiveInteractor version
5
5
  # @return [String] the ActiveInteractor version
6
- VERSION = '1.0.4'
6
+ VERSION = '1.0.5'
7
7
  end
@@ -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
 
@@ -1,19 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  begin
4
- if ENV['CODACY_PROJECT_TOKEN']
5
- require 'codacy-coverage'
6
-
7
- Codacy::Reporter.start
8
- else
9
- require 'simplecov'
10
-
11
- SimpleCov.start do
12
- enable_coverage :branch
13
- add_filter '/spec/'
14
- add_filter '/lib/rails/**/*.rb'
15
- track_files '/lib/**/*.rb'
16
- end
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
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-02-11 00:00:00.000000000 Z
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.4/CHANGELOG.md
205
- documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.0.4
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.4
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/active_interactor/interactor/perform/options_spec.rb
238
- - spec/active_interactor/interactor/worker_spec.rb
239
- - spec/active_interactor/error_spec.rb
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/an_interactor_with_an_existing_context_class_spec.rb
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/an_organizer_with_before_each_callbacks_spec.rb
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/an_interactor_with_validations_on_calling_spec.rb
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/an_interactor_with_around_perform_callbacks_spec.rb
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