axn 0.1.0.pre.alpha.1 → 0.1.0.pre.alpha.1.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 +6 -0
- data/README.md +1 -1
- data/lib/action/context_facade.rb +2 -2
- data/lib/action/contract.rb +6 -6
- data/lib/action/exceptions.rb +1 -1
- data/lib/axn/version.rb +1 -1
- metadata +2 -3
- data/axn.gemspec +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a4820a9fbbd271a71be8a06320e362372d87590246931da17c48bb2299eb4fc
|
4
|
+
data.tar.gz: 18d6743feaaa914640bf3eaac95c67e79ad059179191a0987896c6fd49ead8d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 459807c65792ef1d0624638750f7f14b66150525c9e643d5f48536b98424be935a4548969cc337d1d226cd9b062b6404968f31e95e43da8284b100450aac0d54
|
7
|
+
data.tar.gz: 2fec14a17957558f16bf1f813789b61a54b7b7f84a911acd8d80bffa794f8f1f6e559ee6b66b4668691ff360ed0d916ee28f6af2e5428a55c4428add5b6cd4a4
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -108,7 +108,7 @@ module Action
|
|
108
108
|
|
109
109
|
private
|
110
110
|
|
111
|
-
def exposure_method_name = :
|
111
|
+
def exposure_method_name = :expects
|
112
112
|
end
|
113
113
|
|
114
114
|
# Outbound / External ContextFacade
|
@@ -138,7 +138,7 @@ module Action
|
|
138
138
|
|
139
139
|
private
|
140
140
|
|
141
|
-
def exposure_method_name = :
|
141
|
+
def exposure_method_name = :exposes
|
142
142
|
end
|
143
143
|
|
144
144
|
class Inspector
|
data/lib/action/contract.rb
CHANGED
@@ -34,8 +34,8 @@ module Action
|
|
34
34
|
FieldConfig = Data.define(:field, :validations, :default, :preprocess, :sensitive)
|
35
35
|
|
36
36
|
module ClassMethods
|
37
|
-
def
|
38
|
-
|
37
|
+
def expects(*fields, allow_blank: false, default: nil, preprocess: nil, sensitive: false,
|
38
|
+
**validations)
|
39
39
|
_parse_field_configs(*fields, allow_blank:, default:, preprocess:, sensitive:, **validations).tap do |configs|
|
40
40
|
duplicated = internal_field_configs.map(&:field) & configs.map(&:field)
|
41
41
|
raise Action::DuplicateFieldError, "Duplicate field(s) declared: #{duplicated.join(", ")}" if duplicated.any?
|
@@ -45,7 +45,7 @@ module Action
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def exposes(*fields, allow_blank: false, default: nil, sensitive: false, **validations)
|
49
49
|
_parse_field_configs(*fields, allow_blank:, default:, preprocess: nil, sensitive:, **validations).tap do |configs|
|
50
50
|
duplicated = external_field_configs.map(&:field) & configs.map(&:field)
|
51
51
|
raise Action::DuplicateFieldError, "Duplicate field(s) declared: #{duplicated.join(", ")}" if duplicated.any?
|
@@ -84,16 +84,16 @@ module Action
|
|
84
84
|
def internal_context = @internal_context ||= _build_context_facade(:inbound)
|
85
85
|
def external_context = @external_context ||= _build_context_facade(:outbound)
|
86
86
|
|
87
|
-
# NOTE: ideally no direct access from client code, but we need to
|
87
|
+
# NOTE: ideally no direct access from client code, but we need to expose this for internal Interactor methods
|
88
88
|
# (and passing through control methods to underlying context) in order to avoid rewriting internal methods.
|
89
89
|
def context = external_context
|
90
90
|
|
91
91
|
# Accepts either two positional arguments (key, value) or a hash of key/value pairs
|
92
|
-
def
|
92
|
+
def expose(*args, **kwargs)
|
93
93
|
if args.any?
|
94
94
|
if args.size != 2
|
95
95
|
raise ArgumentError,
|
96
|
-
"
|
96
|
+
"expose must be called with exactly two positional arguments (or a hash of key/value pairs)"
|
97
97
|
end
|
98
98
|
|
99
99
|
kwargs.merge!(args.first => args.last)
|
data/lib/action/exceptions.rb
CHANGED
@@ -42,7 +42,7 @@ module Action
|
|
42
42
|
super()
|
43
43
|
end
|
44
44
|
|
45
|
-
def message = "Attempted to
|
45
|
+
def message = "Attempted to expose unknown key '#{@key}': be sure to declare it with `exposes :#{@key}`"
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
data/lib/axn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: axn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.alpha.1
|
4
|
+
version: 0.1.0.pre.alpha.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kali Donovan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -67,7 +67,6 @@ files:
|
|
67
67
|
- LICENSE.txt
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
|
-
- axn.gemspec
|
71
70
|
- docs/.vitepress/config.mjs
|
72
71
|
- docs/about/index.md
|
73
72
|
- docs/advanced/rough.md
|
data/axn.gemspec
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "lib/axn/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "axn"
|
7
|
-
spec.version = Axn::VERSION
|
8
|
-
spec.authors = ["Kali Donovan"]
|
9
|
-
spec.email = ["kali@teamshares.com"]
|
10
|
-
|
11
|
-
spec.summary = "A terse convention for business logic"
|
12
|
-
spec.description = "Pattern for writing callable service objects with contract validation and error swallowing"
|
13
|
-
spec.homepage = "https://github.com/teamshares/axn"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
# NOTE: uses endless methods from 3, literal value omission from 3.1
|
17
|
-
spec.required_ruby_version = ">= 3.1.0"
|
18
|
-
|
19
|
-
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
20
|
-
# spec.metadata["rubygems_mfa_required"] = "true"
|
21
|
-
|
22
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
24
|
-
spec.metadata["changelog_uri"] = "https://github.com/teamshares/axn/blob/main/CHANGELOG.md"
|
25
|
-
|
26
|
-
# Specify which files should be added to the gem when it is released.
|
27
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
-
spec.files = Dir.chdir(__dir__) do
|
29
|
-
`git ls-files -z`.split("\x0").reject do |f|
|
30
|
-
(File.expand_path(f) == __FILE__) ||
|
31
|
-
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
|
32
|
-
end
|
33
|
-
end
|
34
|
-
spec.bindir = "exe"
|
35
|
-
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
36
|
-
spec.require_paths = ["lib"]
|
37
|
-
|
38
|
-
# Core dependencies
|
39
|
-
spec.add_dependency "activemodel", "> 7.0" # For contract validation
|
40
|
-
spec.add_dependency "activesupport", "> 7.0" # For compact_blank and friends
|
41
|
-
|
42
|
-
# NOTE: for inheritance support, need to specify a fork in consuming applications' Gemfile (see Gemfile here for syntax)
|
43
|
-
spec.add_dependency "interactor", "3.1.2" # We're building on this scaffolding for organizing business logic
|
44
|
-
spec.metadata["rubygems_mfa_required"] = "true"
|
45
|
-
end
|