activeinteractor 0.1.7 → 1.0.0.beta.1
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 +36 -1
- data/README.md +397 -395
- data/lib/active_interactor.rb +12 -30
- data/lib/active_interactor/base.rb +18 -8
- data/lib/active_interactor/context.rb +4 -181
- data/lib/active_interactor/context/attributes.rb +37 -149
- data/lib/active_interactor/context/base.rb +141 -0
- data/lib/active_interactor/context/loader.rb +45 -0
- data/lib/active_interactor/error.rb +22 -15
- data/lib/active_interactor/interactor.rb +24 -57
- data/lib/active_interactor/interactor/callbacks.rb +64 -76
- data/lib/active_interactor/interactor/context.rb +97 -63
- data/lib/active_interactor/interactor/worker.rb +22 -65
- data/lib/active_interactor/organizer.rb +180 -164
- data/lib/active_interactor/version.rb +2 -3
- data/lib/rails/generators/active_interactor.rb +2 -37
- data/lib/rails/generators/active_interactor/application_interactor_generator.rb +23 -0
- data/lib/rails/generators/active_interactor/install_generator.rb +8 -12
- data/lib/rails/generators/active_interactor/templates/application_context.rb +4 -0
- data/lib/rails/generators/{templates/application_interactor.erb → active_interactor/templates/application_interactor.rb} +0 -0
- data/lib/rails/generators/active_interactor/templates/application_organizer.rb +4 -0
- data/lib/rails/generators/active_interactor/templates/initializer.erb +5 -0
- data/lib/rails/generators/interactor/context/rspec_generator.rb +19 -0
- data/lib/rails/generators/interactor/context/templates/rspec.erb +7 -0
- data/lib/rails/generators/interactor/context/templates/test_unit.erb +9 -0
- data/lib/rails/generators/interactor/context/test_unit_generator.rb +19 -0
- data/lib/rails/generators/interactor/context_generator.rb +19 -0
- data/lib/rails/generators/interactor/interactor_generator.rb +8 -3
- data/lib/rails/generators/interactor/organizer_generator.rb +8 -3
- data/lib/rails/generators/interactor/rspec_generator.rb +4 -3
- data/lib/rails/generators/interactor/templates/context.erb +4 -0
- data/lib/rails/generators/{templates → interactor/templates}/interactor.erb +0 -0
- data/lib/rails/generators/{templates → interactor/templates}/organizer.erb +1 -1
- data/lib/rails/generators/{templates → interactor/templates}/rspec.erb +0 -0
- data/lib/rails/generators/{templates → interactor/templates}/test_unit.erb +0 -0
- data/lib/rails/generators/interactor/test_unit_generator.rb +4 -3
- data/spec/active_interactor/base_spec.rb +51 -0
- data/spec/active_interactor/context/base_spec.rb +229 -0
- data/spec/active_interactor/error_spec.rb +43 -0
- data/spec/active_interactor/interactor/worker_spec.rb +89 -0
- data/spec/active_interactor/organizer_spec.rb +178 -0
- data/spec/active_interactor_spec.rb +26 -0
- data/spec/integration/basic_callback_integration_spec.rb +355 -0
- data/spec/integration/basic_context_integration_spec.rb +73 -0
- data/spec/integration/basic_integration_spec.rb +220 -0
- data/spec/integration/basic_validations_integration_spec.rb +204 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/helpers/factories.rb +41 -0
- data/spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb +99 -0
- data/spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb +58 -0
- data/spec/support/shared_examples/a_class_with_interactor_methods_example.rb +21 -0
- data/spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb +39 -0
- data/spec/support/spec_helpers.rb +7 -0
- metadata +68 -138
- data/lib/active_interactor/configuration.rb +0 -38
- data/lib/active_interactor/interactor/execution.rb +0 -24
- data/lib/rails/generators/templates/initializer.erb +0 -15
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveInteractor
|
4
|
-
# The Configuration object for the ActiveInteractor gem
|
5
|
-
#
|
6
|
-
# @author Aaron Allen <hello@aaronmallen.me>
|
7
|
-
# @since 0.0.1
|
8
|
-
# @version 0.2
|
9
|
-
#
|
10
|
-
# @!attribute [rw] logger
|
11
|
-
# @return [Logger] an instance of Logger
|
12
|
-
# @!attribute [rw] dir_name
|
13
|
-
# @return [String] The directory name interactors are generated in
|
14
|
-
class Configuration
|
15
|
-
# The default configuration options for {Configuration}
|
16
|
-
# @return [Hash{Symbol => *}]
|
17
|
-
DEFAULTS = {
|
18
|
-
logger: Logger.new(STDOUT),
|
19
|
-
dir_name: 'interactors'
|
20
|
-
}.freeze
|
21
|
-
|
22
|
-
attr_accessor :logger, :dir_name
|
23
|
-
|
24
|
-
# A new instance of {Configuration}
|
25
|
-
# @param options [Hash{Symbol => *}] the options to initialize the
|
26
|
-
# configuration with.
|
27
|
-
# @option options [Logger] :logger the logger ActiveInteractor should
|
28
|
-
# use for logging
|
29
|
-
# @option options [String] :dir_name he directory name interactors are generated in
|
30
|
-
# @return [ActiveInteractor::Configuration] a new instance of {Configuration}
|
31
|
-
def initialize(options = {})
|
32
|
-
options = DEFAULTS.merge(options.dup || {}).slice(*DEFAULTS.keys)
|
33
|
-
options.each_key do |attribute|
|
34
|
-
instance_variable_set("@#{attribute}", options[attribute])
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ActiveInteractor
|
4
|
-
module Interactor
|
5
|
-
# Provides worker methods to included classes
|
6
|
-
#
|
7
|
-
# @author Aaron Allen <hello@aaronmallen.me>
|
8
|
-
# @since 0.0.2
|
9
|
-
# @version 0.2
|
10
|
-
module Execution
|
11
|
-
extend ActiveSupport::Concern
|
12
|
-
|
13
|
-
included do
|
14
|
-
delegate :execute_perform, :execute_perform!, :execute_rollback, to: :worker
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def worker
|
20
|
-
Worker.new(self)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_interactor'
|
4
|
-
|
5
|
-
ActiveInteractor.configure do |config|
|
6
|
-
# Set the ActiveInteractor.logger to Rails.logger
|
7
|
-
config.logger = Rails.logger
|
8
|
-
|
9
|
-
# Set the default directory for interactors
|
10
|
-
<%- if directory != 'interactors' -%>
|
11
|
-
config.dir_name = '<%= directory %>'
|
12
|
-
<%- else -%>
|
13
|
-
# config.dir_name = 'interactors'
|
14
|
-
<%- end -%>
|
15
|
-
end
|