activeinteractor 2.0.0.alpha.2.3.2 → 2.0.0.alpha.2.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_interactor/{has_active_model_errors.rb → active_model_error_methods.rb} +3 -1
- data/lib/active_interactor/base.rb +5 -108
- data/lib/active_interactor/context/base.rb +2 -3
- data/lib/active_interactor/context/result.rb +20 -0
- data/lib/active_interactor/context.rb +2 -0
- data/lib/active_interactor/errors.rb +13 -0
- data/lib/active_interactor/interactor/base.rb +43 -0
- data/lib/active_interactor/interactor/context_methods.rb +79 -0
- data/lib/active_interactor/interactor/interaction_methods.rb +38 -0
- data/lib/active_interactor/interactor.rb +12 -0
- data/lib/active_interactor/result.rb +96 -3
- data/lib/active_interactor/type/{has_types.rb → decleration_methods.rb} +1 -1
- data/lib/active_interactor/type.rb +2 -1
- data/lib/active_interactor.rb +32 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d75851d221fb7d266849601c5eef65939edfb615419818393ca9ea9b165a4279
|
4
|
+
data.tar.gz: '08f62a487d21f34df03f63b0dc112010df68fbb0a6aa6f3931d972eb0dbaed36'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 533fa79817a6d0598c1dac316da54f19ac5e96067ede7f65869f26a2c84b5481a134fab044ed947061d6a19f9021c829dc428456e4cb25483ea276b44c5ba6a7
|
7
|
+
data.tar.gz: 9efe50f237b0bd204678158dd9ba27482b93e640193f8c3f3cbd71025d2b46fb1490bbb19bf25b31adeecdb02298947dbf41a1bd7cb03659c3bc1871faf1605e
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveInteractor
|
4
|
-
|
4
|
+
# @private
|
5
|
+
module ActiveModelErrorMethods
|
5
6
|
extend ActiveSupport::Concern
|
6
7
|
|
7
8
|
attr_reader :errors
|
8
9
|
|
10
|
+
# @private
|
9
11
|
module ClassMethods
|
10
12
|
def human_attribute_name(attribute, _options = {})
|
11
13
|
attribute.respond_to?(:to_s) ? attribute.to_s.humanize : attribute
|
@@ -1,112 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveInteractor
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
delegate :returns, :field_names, :fields, to: :output_context_class
|
10
|
-
|
11
|
-
def input_context_class
|
12
|
-
@input_context_class ||= const_set(:InputContext, Class.new(Context::Input))
|
13
|
-
end
|
14
|
-
|
15
|
-
def accepts_arguments_matching(set_input_context_class)
|
16
|
-
@input_context_class = set_input_context_class
|
17
|
-
end
|
18
|
-
alias input_context accepts_arguments_matching
|
19
|
-
|
20
|
-
def output_context_class
|
21
|
-
@output_context_class ||= const_set(:OutputContext, Class.new(Context::Output))
|
22
|
-
end
|
23
|
-
|
24
|
-
def perform!(input_context = {})
|
25
|
-
new(input_context).perform!
|
26
|
-
end
|
27
|
-
|
28
|
-
def perform(input_context = {})
|
29
|
-
perform!(input_context)
|
30
|
-
rescue Error => e
|
31
|
-
e.result
|
32
|
-
rescue StandardError => e
|
33
|
-
Result.failure(errors: e.message)
|
34
|
-
end
|
35
|
-
|
36
|
-
def returns_data_matching(set_output_context_class)
|
37
|
-
@output_context_class = set_output_context_class
|
38
|
-
end
|
39
|
-
alias output_context returns_data_matching
|
40
|
-
|
41
|
-
def runtime_context_class
|
42
|
-
@runtime_context_class ||= begin
|
43
|
-
context_class = const_set(:RuntimeContext, Class.new(Context::Runtime))
|
44
|
-
context_class.send(:attribute_set).merge(input_context_class.send(:attribute_set).attributes)
|
45
|
-
context_class.send(:attribute_set).merge(output_context_class.send(:attribute_set).attributes)
|
46
|
-
context_class
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def initialize(input = {})
|
52
|
-
@raw_input = input.dup
|
53
|
-
validate_input_and_generate_runtime_context!
|
54
|
-
end
|
55
|
-
|
56
|
-
def perform!
|
57
|
-
with_notification(:perform) do |payload|
|
58
|
-
interact
|
59
|
-
generate_and_validate_output_context!
|
60
|
-
payload[:result] = Result.success(data: @output)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def perform
|
65
|
-
perform!
|
66
|
-
rescue Error => e
|
67
|
-
e.result
|
68
|
-
rescue StandardError => e
|
69
|
-
Result.failure(errors: e.message)
|
70
|
-
end
|
71
|
-
|
72
|
-
def interact; end
|
73
|
-
def rollback; end
|
74
|
-
|
75
|
-
protected
|
76
|
-
|
77
|
-
attr_accessor :context
|
78
|
-
|
79
|
-
def fail!(errors = {})
|
80
|
-
result = nil
|
81
|
-
with_notification(:rollback) do |payload|
|
82
|
-
rollback
|
83
|
-
result = Result.failure(data: parse_output!, errors: errors)
|
84
|
-
payload[:result] = result
|
85
|
-
end
|
86
|
-
|
87
|
-
raise Error, result
|
88
|
-
end
|
89
|
-
|
90
|
-
def generate_and_validate_output_context!
|
91
|
-
@output = self.class.output_context_class.new(context.attributes)
|
92
|
-
@output.validate!
|
93
|
-
return @output if @output.errors.empty?
|
94
|
-
|
95
|
-
raise Error, Result.failure(errors: @output.errors, status: Result::STATUS[:failed_at_output])
|
96
|
-
end
|
97
|
-
|
98
|
-
def validate_input_and_generate_runtime_context!
|
99
|
-
@input = self.class.input_context_class.new(@raw_input)
|
100
|
-
@input.validate!
|
101
|
-
return (@context = self.class.runtime_context_class.new(@raw_input)) if @input.errors.empty?
|
102
|
-
|
103
|
-
raise Error, Result.failure(errors: @input.errors, status: Result::STATUS[:failed_at_input])
|
104
|
-
end
|
105
|
-
|
106
|
-
def with_notification(action)
|
107
|
-
ActiveSupport::Notifications.instrument("#{self.class.name}::#{action.to_s.classify}") do |payload|
|
108
|
-
yield payload if block_given?
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
4
|
+
# The Main interface for ActiveInteractor
|
5
|
+
#
|
6
|
+
# @deprecated will be removed in version 2.0.0-alpha.3.0.0
|
7
|
+
# use {ActiveInteractor::Interactor::Base} instead
|
8
|
+
class Base < ActiveInteractor::Interactor::Base; end
|
112
9
|
end
|
@@ -3,11 +3,10 @@
|
|
3
3
|
module ActiveInteractor
|
4
4
|
module Context
|
5
5
|
class Base
|
6
|
-
include
|
7
|
-
include HasActiveModelErrors
|
6
|
+
include ActiveModelErrorMethods
|
8
7
|
include AttributeRegistration
|
9
8
|
include AttributeAssignment
|
10
|
-
include Type::
|
9
|
+
include Type::DeclerationMethods
|
11
10
|
|
12
11
|
def initialize(attributes = {})
|
13
12
|
super
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveInteractor
|
4
|
+
module Context
|
5
|
+
class Result
|
6
|
+
def self.register_owner(owner)
|
7
|
+
owner.const_set(:ResultContext, Class.new(self))
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.for_output_context(owner, context)
|
11
|
+
context.fields.each_key { |field| owner::ResultContext.send(:attr_reader, field) }
|
12
|
+
owner::ResultContext.new(context.fields)
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(attributes = {})
|
16
|
+
attributes.each_pair { |key, value| instance_variable_set(:"@#{key}", value) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveInteractor
|
4
|
+
# The Context namespace
|
4
5
|
module Context
|
5
6
|
extend ActiveSupport::Autoload
|
6
7
|
|
@@ -11,6 +12,7 @@ module ActiveInteractor
|
|
11
12
|
autoload :Base
|
12
13
|
autoload :Input
|
13
14
|
autoload :Output
|
15
|
+
autoload :Result
|
14
16
|
autoload :Runtime
|
15
17
|
end
|
16
18
|
end
|
@@ -1,9 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveInteractor
|
4
|
+
# Raised when an interactor fails
|
5
|
+
#
|
6
|
+
# @!attribute [r] result
|
7
|
+
# @return [ActiveInteractor::Result] An instance of {ActiveInteractor::Result} for the
|
8
|
+
# {ActiveInteractor::Interactor::Base interactor} that failed
|
4
9
|
class Error < StandardError
|
5
10
|
attr_reader :result
|
6
11
|
|
12
|
+
# Create a new instance of {ActiveInteractor::Error}
|
13
|
+
#
|
14
|
+
# @param result [ActiveInteractor::Result] An instance of {ActiveInteractor::Result} for the
|
15
|
+
# {ActiveInteractor::Interactor::Base interactor} that failed
|
16
|
+
# @param message [String] The error message
|
17
|
+
#
|
18
|
+
# @private
|
19
|
+
# @return [ActiveInteractor::Error]
|
7
20
|
def initialize(result, message = nil)
|
8
21
|
@result = result
|
9
22
|
super(message)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveInteractor
|
4
|
+
module Interactor
|
5
|
+
class Base
|
6
|
+
include ContextMethods
|
7
|
+
include InteractionMethods
|
8
|
+
include Type::DeclerationMethods
|
9
|
+
|
10
|
+
def initialize(input = {})
|
11
|
+
@raw_input = input.dup
|
12
|
+
validate_input_and_generate_runtime_context!
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform!
|
16
|
+
with_notification(:perform) do |payload|
|
17
|
+
interact
|
18
|
+
generate_and_validate_output_context!
|
19
|
+
payload[:result] = Result.success(data: output_to_result_context!)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
def fail!(errors = {})
|
26
|
+
result = nil
|
27
|
+
with_notification(:rollback) do |payload|
|
28
|
+
rollback
|
29
|
+
result = Result.failure(data: parse_output!, errors: errors)
|
30
|
+
payload[:result] = result
|
31
|
+
end
|
32
|
+
|
33
|
+
raise Error, result
|
34
|
+
end
|
35
|
+
|
36
|
+
def with_notification(action)
|
37
|
+
ActiveSupport::Notifications.instrument("#{self.class.name}::#{action.to_s.classify}") do |payload|
|
38
|
+
yield payload if block_given?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveInteractor
|
4
|
+
module Interactor
|
5
|
+
module ContextMethods
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
delegate :argument, :argument_names, :arguments, to: :input_context_class
|
10
|
+
delegate :returns, :field_names, :fields, to: :output_context_class
|
11
|
+
|
12
|
+
def input_context_class
|
13
|
+
@input_context_class ||= const_set(:InputContext, Class.new(Context::Input))
|
14
|
+
end
|
15
|
+
|
16
|
+
def accepts_arguments_matching(set_input_context_class)
|
17
|
+
@input_context_class = set_input_context_class
|
18
|
+
end
|
19
|
+
alias input_context accepts_arguments_matching
|
20
|
+
alias input_type accepts_arguments_matching
|
21
|
+
|
22
|
+
def output_context_class
|
23
|
+
@output_context_class ||= const_set(:OutputContext, Class.new(Context::Output))
|
24
|
+
end
|
25
|
+
|
26
|
+
def returns_data_matching(set_output_context_class)
|
27
|
+
@output_context_class = set_output_context_class
|
28
|
+
end
|
29
|
+
alias output_context returns_data_matching
|
30
|
+
alias output_type returns_data_matching
|
31
|
+
|
32
|
+
def runtime_context_class
|
33
|
+
@runtime_context_class ||= begin
|
34
|
+
context_class = const_set(:RuntimeContext, Class.new(Context::Runtime))
|
35
|
+
context_class.send(:attribute_set).merge(input_context_class.send(:attribute_set).attributes)
|
36
|
+
context_class.send(:attribute_set).merge(output_context_class.send(:attribute_set).attributes)
|
37
|
+
context_class
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def result_context
|
44
|
+
@result_context ||= Context::Result.register_owner(self)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
included do
|
49
|
+
extend ClassMethods
|
50
|
+
|
51
|
+
protected
|
52
|
+
|
53
|
+
attr_reader :context
|
54
|
+
end
|
55
|
+
|
56
|
+
protected # rubocop:disable Lint/UselessAccessModifier
|
57
|
+
|
58
|
+
def generate_and_validate_output_context!
|
59
|
+
@output = self.class.output_context_class.new(context.attributes)
|
60
|
+
@output.validate!
|
61
|
+
return if @output.errors.empty?
|
62
|
+
|
63
|
+
raise Error, Result.failure(errors: @output.errors, status: Result::STATUS[:failed_at_output])
|
64
|
+
end
|
65
|
+
|
66
|
+
def output_to_result_context!
|
67
|
+
self.class.send(:result_context).for_output_context(self.class, @output)
|
68
|
+
end
|
69
|
+
|
70
|
+
def validate_input_and_generate_runtime_context!
|
71
|
+
@input = self.class.input_context_class.new(@raw_input)
|
72
|
+
@input.validate!
|
73
|
+
return (@context = self.class.runtime_context_class.new(@raw_input)) if @input.errors.empty?
|
74
|
+
|
75
|
+
raise Error, Result.failure(errors: @input.errors, status: Result::STATUS[:failed_at_input])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ActiveInteractor
|
4
|
+
module Interactor
|
5
|
+
module InteractionMethods
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def perform!(input_context = {})
|
10
|
+
new(input_context).perform!
|
11
|
+
end
|
12
|
+
|
13
|
+
def perform(input_context = {})
|
14
|
+
perform!(input_context)
|
15
|
+
rescue Error => e
|
16
|
+
e.result
|
17
|
+
rescue StandardError => e
|
18
|
+
Result.failure(errors: e.message)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
included do
|
23
|
+
extend ClassMethods
|
24
|
+
end
|
25
|
+
|
26
|
+
def perform
|
27
|
+
perform!
|
28
|
+
rescue Error => e
|
29
|
+
e.result
|
30
|
+
rescue StandardError => e
|
31
|
+
Result.failure(errors: e.message)
|
32
|
+
end
|
33
|
+
|
34
|
+
def interact; end
|
35
|
+
def rollback; end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,11 +1,64 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveInteractor
|
4
|
+
# The object returned by an {ActiveInteractor::Interactor::Base interactor}
|
5
|
+
#
|
6
|
+
# @!attribute [r] data
|
7
|
+
#
|
8
|
+
# @example Given an {ActiveInteractor::Interactor::Base interactor} that creates an ActiveRecord User
|
9
|
+
# class CreateUser < ActiveInteractor::Interactor::Base
|
10
|
+
# argument :login, String, 'The login for the User', required: true
|
11
|
+
# argument :password, String, 'The password for the User', required: true
|
12
|
+
# argument :password_confirmation, String, 'The password confirmation for the user', required: true
|
13
|
+
#
|
14
|
+
# returns :user, User, 'The created User', required: true
|
15
|
+
#
|
16
|
+
# def interact
|
17
|
+
# context.user = User.new(context)
|
18
|
+
# fail!(context.user.errors) unless context.user.save
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
#
|
22
|
+
# result = CreateUser.perform(login: 'johndoe', password: 'password', password_confirmation: 'password')
|
23
|
+
# result.data.user
|
24
|
+
#
|
25
|
+
# #=> <# User @login='johndoe'>
|
26
|
+
#
|
27
|
+
# @return [ActiveInteractor::Context::Result] the data returned by the
|
28
|
+
# {ActiveInteractor::Interactor::Base interactor}
|
29
|
+
#
|
30
|
+
# @!attribute [r] errors
|
31
|
+
# @return [ActiveModel::Errors] the errors returned by the
|
32
|
+
# {ActiveInteractor::Interactor::Base interactor}
|
33
|
+
# @see https://github.com/rails/rails/blob/main/activemodel/lib/active_model/errors.rb ActiveModel::Errors
|
4
34
|
class Result
|
5
|
-
include
|
35
|
+
include ActiveModelErrorMethods
|
6
36
|
|
37
|
+
# @!method to_json
|
38
|
+
# The {ActiveInteractor::Interactor::Base result} as a Hash
|
39
|
+
#
|
40
|
+
# @example When an {ActiveInteractor::Interactor::Base interactor} succeeds
|
41
|
+
# result = CreateUser.perform(login: 'johndoe', password: 'password', password_confirmation: 'password')
|
42
|
+
# result.to_hash
|
43
|
+
#
|
44
|
+
# #=> { :success => true, :errors => {}, :data => { :login => 'johndoe' } }
|
45
|
+
#
|
46
|
+
# @example When an {ActiveInteractor::Interactor::Base interactor} fails
|
47
|
+
# result = CreateUser.perform(login: 'johndoe', password: 'password', password_confirmation: 'notpassword')
|
48
|
+
# result.to_hash
|
49
|
+
#
|
50
|
+
# #=> {
|
51
|
+
# #=> :success => false,
|
52
|
+
# #=> :errors => { :password_confirmation => ["doesn't match Password"] },
|
53
|
+
# #=> :data => { :login => 'johndoe' }
|
54
|
+
# #=> }
|
55
|
+
#
|
56
|
+
# @deprecated will be removed in version 2.0.0-alpha.3.0.0
|
57
|
+
# use {#to_hash} instead
|
58
|
+
# @return [Hash {Symbol => Boolean, Hash}]
|
7
59
|
delegate :to_json, to: :to_hash
|
8
60
|
|
61
|
+
# @private
|
9
62
|
STATUS = {
|
10
63
|
success: 0,
|
11
64
|
failed_at_input: 1,
|
@@ -16,10 +69,12 @@ module ActiveInteractor
|
|
16
69
|
attr_reader :data
|
17
70
|
|
18
71
|
class << self
|
72
|
+
# @private
|
19
73
|
def success(data: {})
|
20
74
|
new(status: STATUS[:success], data: data)
|
21
75
|
end
|
22
76
|
|
77
|
+
# @private
|
23
78
|
def failure(data: {}, errors: {}, status: STATUS[:failed_at_runtime])
|
24
79
|
result = new(status: status, data: data)
|
25
80
|
parse_errors(errors).each_pair do |attribute, messages|
|
@@ -43,32 +98,70 @@ module ActiveInteractor
|
|
43
98
|
end
|
44
99
|
|
45
100
|
private_class_method :new
|
46
|
-
|
101
|
+
# @private
|
47
102
|
def initialize(status:, data: {})
|
48
103
|
@status = status
|
49
104
|
@data = data
|
50
105
|
@errors = ActiveModel::Errors.new(self)
|
51
106
|
end
|
52
107
|
|
108
|
+
# Whether or not the {ActiveInteractor::Interactor::Base result} is a failure
|
109
|
+
#
|
110
|
+
# @example When an {ActiveInteractor::Interactor::Base interactor} fails
|
111
|
+
# result = CreateUser.perform(login: 'johndoe', password: 'password', password_confirmation: 'notpassword')
|
112
|
+
# result.failure?
|
113
|
+
#
|
114
|
+
# #=> true
|
115
|
+
#
|
116
|
+
# @example When an {ActiveInteractor::Interactor::Base interactor} succeeds
|
117
|
+
# result = CreateUser.perform(login: 'johndoe', password: 'password', password_confirmation: 'password')
|
118
|
+
# result.failure?
|
119
|
+
#
|
120
|
+
# #=> false
|
121
|
+
#
|
122
|
+
# @return [Boolean]
|
53
123
|
def failure?
|
54
124
|
!success?
|
55
125
|
end
|
56
126
|
alias failed? failure?
|
57
127
|
|
128
|
+
# @private
|
58
129
|
def read_attribute_for_validation(attribute_name)
|
59
130
|
data.send(attribute_name.to_sym)
|
60
131
|
end
|
61
132
|
|
133
|
+
# Whether or not the {ActiveInteractor::Interactor::Base result} is a success
|
134
|
+
#
|
135
|
+
# @return [Boolean]
|
62
136
|
def success?
|
63
137
|
@status == STATUS[:success]
|
64
138
|
end
|
65
139
|
alias successful? success?
|
66
140
|
|
141
|
+
# The {ActiveInteractor::Interactor::Base result} as a Hash
|
142
|
+
#
|
143
|
+
# @example When an {ActiveInteractor::Interactor::Base interactor} succeeds
|
144
|
+
# result = CreateUser.perform(login: 'johndoe', password: 'password', password_confirmation: 'password')
|
145
|
+
# result.to_hash
|
146
|
+
#
|
147
|
+
# #=> { :success => true, :errors => {}, :data => { :login => 'johndoe' } }
|
148
|
+
#
|
149
|
+
# @example When an {ActiveInteractor::Interactor::Base interactor} fails
|
150
|
+
# result = CreateUser.perform(login: 'johndoe', password: 'password', password_confirmation: 'notpassword')
|
151
|
+
# result.to_hash
|
152
|
+
#
|
153
|
+
# #=> {
|
154
|
+
# #=> :success => false,
|
155
|
+
# #=> :errors => { :password_confirmation => ["doesn't match Password"] },
|
156
|
+
# #=> :data => { :login => 'johndoe' }
|
157
|
+
# #=> }
|
158
|
+
#
|
159
|
+
# @return [Hash {Symbol => Boolean, Hash}]
|
67
160
|
def to_hash
|
68
161
|
{
|
69
162
|
success: success?,
|
70
163
|
errors: errors.to_hash,
|
71
|
-
data: data.
|
164
|
+
data: data.to_json
|
72
165
|
}
|
73
166
|
end
|
74
167
|
alias to_h to_hash
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveInteractor
|
4
|
+
# @private
|
4
5
|
module Type
|
5
6
|
extend ActiveSupport::Autoload
|
6
7
|
|
7
8
|
autoload :Base
|
8
9
|
autoload :Boolean
|
9
|
-
autoload :
|
10
|
+
autoload :DeclerationMethods
|
10
11
|
autoload :List
|
11
12
|
autoload :Union
|
12
13
|
end
|
data/lib/active_interactor.rb
CHANGED
@@ -6,12 +6,43 @@ require 'active_support/core_ext'
|
|
6
6
|
|
7
7
|
require_relative 'active_interactor/errors'
|
8
8
|
|
9
|
+
# ## License
|
10
|
+
#
|
11
|
+
# Copyright (c) 2023 Aaron Allen
|
12
|
+
#
|
13
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
14
|
+
# of this software and associated documentation files (the "Software"), to deal
|
15
|
+
# in the Software without restriction, including without limitation the rights
|
16
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
17
|
+
# copies of the Software, and to permit persons to whom the Software is
|
18
|
+
# furnished to do so, subject to the following conditions:
|
19
|
+
#
|
20
|
+
# The above copyright notice and this permission notice shall be included in
|
21
|
+
# all copies or substantial portions of the Software.
|
22
|
+
#
|
23
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
24
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
25
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
26
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
27
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
28
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
29
|
+
# THE SOFTWARE.
|
30
|
+
#
|
31
|
+
# {file:CHANGELOG.md Changelog}
|
32
|
+
#
|
33
|
+
# {file:HUMANS.md Acknowledgements}
|
34
|
+
#
|
35
|
+
# {file:SECURITY.md Security Policy}
|
36
|
+
#
|
37
|
+
# @author {hello@aaronmallen.me Aaron Allen}
|
38
|
+
|
9
39
|
module ActiveInteractor
|
10
40
|
extend ActiveSupport::Autoload
|
11
41
|
|
42
|
+
autoload :ActiveModelErrorMethods
|
12
43
|
autoload :Base
|
13
44
|
autoload :Context
|
14
|
-
autoload :
|
45
|
+
autoload :Interactor
|
15
46
|
autoload :Result
|
16
47
|
autoload :Type
|
17
48
|
end
|
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: 2.0.0.alpha.2.3.
|
4
|
+
version: 2.0.0.alpha.2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- LICENSE
|
64
64
|
- README.md
|
65
65
|
- lib/active_interactor.rb
|
66
|
+
- lib/active_interactor/active_model_error_methods.rb
|
66
67
|
- lib/active_interactor/base.rb
|
67
68
|
- lib/active_interactor/context.rb
|
68
69
|
- lib/active_interactor/context/attribute.rb
|
@@ -72,14 +73,18 @@ files:
|
|
72
73
|
- lib/active_interactor/context/base.rb
|
73
74
|
- lib/active_interactor/context/input.rb
|
74
75
|
- lib/active_interactor/context/output.rb
|
76
|
+
- lib/active_interactor/context/result.rb
|
75
77
|
- lib/active_interactor/context/runtime.rb
|
76
78
|
- lib/active_interactor/errors.rb
|
77
|
-
- lib/active_interactor/
|
79
|
+
- lib/active_interactor/interactor.rb
|
80
|
+
- lib/active_interactor/interactor/base.rb
|
81
|
+
- lib/active_interactor/interactor/context_methods.rb
|
82
|
+
- lib/active_interactor/interactor/interaction_methods.rb
|
78
83
|
- lib/active_interactor/result.rb
|
79
84
|
- lib/active_interactor/type.rb
|
80
85
|
- lib/active_interactor/type/base.rb
|
81
86
|
- lib/active_interactor/type/boolean.rb
|
82
|
-
- lib/active_interactor/type/
|
87
|
+
- lib/active_interactor/type/decleration_methods.rb
|
83
88
|
- lib/active_interactor/type/list.rb
|
84
89
|
- lib/active_interactor/type/union.rb
|
85
90
|
- sig/active_interactor.rbs
|
@@ -88,9 +93,10 @@ licenses:
|
|
88
93
|
- MIT
|
89
94
|
metadata:
|
90
95
|
bug_tracker_uri: https://github.com/activeinteractor/activeinteractor/issues
|
91
|
-
changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.2.3.
|
96
|
+
changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.2.3.4/CHANGELOG.md
|
92
97
|
homepage_uri: https://github.com/activeinteractor/activeinteractor
|
93
|
-
source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.2.3.
|
98
|
+
source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.2.3.4
|
99
|
+
documentation_uri: https://api.activeinteractor.io
|
94
100
|
wiki_uri: https://github.com/activeinteractor/activeinteractor/wiki
|
95
101
|
rubygems_mfa_required: 'true'
|
96
102
|
post_install_message:
|