interactor_support 1.0.1 → 1.0.3
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/.prettierignore +1 -0
- data/.yardopts +19 -0
- data/CHANGELOG.md +10 -0
- data/README.md +258 -5
- data/lib/interactor_support/actions.rb +31 -0
- data/lib/interactor_support/concerns/findable.rb +64 -20
- data/lib/interactor_support/concerns/skippable.rb +42 -0
- data/lib/interactor_support/concerns/transactionable.rb +37 -0
- data/lib/interactor_support/concerns/transformable.rb +78 -15
- data/lib/interactor_support/concerns/updatable.rb +43 -1
- data/lib/interactor_support/configuration.rb +32 -9
- data/lib/interactor_support/core.rb +19 -1
- data/lib/interactor_support/request_object.rb +131 -19
- data/lib/interactor_support/validations.rb +89 -9
- data/lib/interactor_support/version.rb +1 -1
- data/lib/interactor_support.rb +44 -0
- metadata +4 -2
data/lib/interactor_support.rb
CHANGED
|
@@ -12,15 +12,59 @@ require_relative 'interactor_support/configuration'
|
|
|
12
12
|
|
|
13
13
|
Dir[File.join(__dir__, 'interactor_support/concerns/*.rb')].sort.each { |file| require file }
|
|
14
14
|
|
|
15
|
+
##
|
|
16
|
+
# InteractorSupport is a modular DSL for building expressive, validated, and
|
|
17
|
+
# transactional service objects using the [Interactor](https://github.com/collectiveidea/interactor) gem.
|
|
18
|
+
#
|
|
19
|
+
# It enhances interactors with powerful helpers like:
|
|
20
|
+
# - `Actions` for data loading, transformation, and persistence
|
|
21
|
+
# - `Validations` for context-aware presence/type/inclusion checks
|
|
22
|
+
# - `RequestObject` for clean, validated, form-like parameter objects
|
|
23
|
+
#
|
|
24
|
+
# It also provides configuration options to control request object behavior.
|
|
25
|
+
#
|
|
26
|
+
# @example Basic usage
|
|
27
|
+
# class CreateUser
|
|
28
|
+
# include Interactor
|
|
29
|
+
# include InteractorSupport
|
|
30
|
+
#
|
|
31
|
+
# required :email, :name
|
|
32
|
+
#
|
|
33
|
+
# transform :email, with: [:strip, :downcase]
|
|
34
|
+
#
|
|
35
|
+
# find_by :account
|
|
36
|
+
#
|
|
37
|
+
# update :user, attributes: { email: :email, name: :name }
|
|
38
|
+
# end
|
|
39
|
+
#
|
|
40
|
+
# @example Configuration
|
|
41
|
+
# InteractorSupport.configure do |config|
|
|
42
|
+
# config.request_object_behavior = :returns_self
|
|
43
|
+
# config.request_object_key_type = :symbol
|
|
44
|
+
# end
|
|
45
|
+
#
|
|
46
|
+
# @see InteractorSupport::Actions
|
|
47
|
+
# @see InteractorSupport::Validations
|
|
48
|
+
# @see InteractorSupport::RequestObject
|
|
49
|
+
# @see InteractorSupport::Configuration
|
|
15
50
|
module InteractorSupport
|
|
16
51
|
extend ActiveSupport::Concern
|
|
17
52
|
|
|
18
53
|
class << self
|
|
54
|
+
##
|
|
55
|
+
# Allows external configuration of InteractorSupport.
|
|
56
|
+
#
|
|
57
|
+
# @yieldparam config [InteractorSupport::Configuration] the global configuration object
|
|
58
|
+
# @return [void]
|
|
19
59
|
def configure
|
|
20
60
|
self.configuration ||= Configuration.new
|
|
21
61
|
yield(configuration) if block_given?
|
|
22
62
|
end
|
|
23
63
|
|
|
64
|
+
##
|
|
65
|
+
# Returns the global InteractorSupport configuration object.
|
|
66
|
+
#
|
|
67
|
+
# @return [InteractorSupport::Configuration]
|
|
24
68
|
def configuration
|
|
25
69
|
@configuration ||= Configuration.new
|
|
26
70
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: interactor_support
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Charlie Mitchell
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-04-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
@@ -17,8 +17,10 @@ executables: []
|
|
|
17
17
|
extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
|
19
19
|
files:
|
|
20
|
+
- ".prettierignore"
|
|
20
21
|
- ".rspec"
|
|
21
22
|
- ".rubocop.yml"
|
|
23
|
+
- ".yardopts"
|
|
22
24
|
- CHANGELOG.md
|
|
23
25
|
- CODE_OF_CONDUCT.md
|
|
24
26
|
- LICENSE.txt
|