clean-architecture 4.0.1 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/README.md +16 -16
- data/clean-architecture.gemspec +1 -1
- data/lib/clean_architecture/entities/targeted_parameters.rb +3 -3
- data/lib/clean_architecture/entities/untargeted_parameters.rb +3 -3
- data/lib/clean_architecture/interfaces/base_parameters.rb +1 -1
- data/lib/clean_architecture/version.rb +1 -1
- data/sorbet/rbi/hidden-definitions/errors.txt +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 428e702a6403538a70c6a095576f6eaf6cc3c50396369e2a6909d5a98f6b7abe
|
4
|
+
data.tar.gz: 47f51f5740280413a09444387a95dac0c5ea05aa63a1b6a3f9e34aacb43b2723
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934c13671b48636c3441dbde2843ae47c5e4d4b0c6dac5ae1ae347839336f04ea7f7baf600ec4003429d0a6cce81b67850bf1ab69a39b138cb01506fcf942835
|
7
|
+
data.tar.gz: 506932bad509e26d0f898ca94ff3256edf0034ac84aea2d694d249d7dbf46f80ed83d591ba2477faf6d5e34144fc235b99661f10d30cafae4438f9128104145f
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
+
5.0.0
|
2
|
+
|
3
|
+
* Rename persistence -> gateway to be consistent with the pattern used through our systems
|
4
|
+
|
1
5
|
4.0.1
|
2
6
|
|
3
|
-
*
|
7
|
+
* CleanArchitecture::Serializers::JsonResponseFromResult: Pass the success value to the proc
|
4
8
|
|
5
9
|
4.0.0
|
6
10
|
|
data/README.md
CHANGED
@@ -97,7 +97,7 @@ We satisfy the SRP by following these rules:
|
|
97
97
|
|
98
98
|
We satisfy the OCP, LSP & DIP by following these rules:
|
99
99
|
|
100
|
-
- We create a clean boundary between our business logic, our
|
100
|
+
- We create a clean boundary between our business logic, our gateway and our application-specific classes using interfaces
|
101
101
|
- We use interfaces wherever possible, allowing concrete implementations of those interfaces to be extended without breaking the contract
|
102
102
|
- We write unit tests against interfaces, never against concrete implementations (unless interfaces don't exist)
|
103
103
|
|
@@ -157,7 +157,7 @@ We satisfy the SAP by:
|
|
157
157
|
|
158
158
|
### Practical suggestions for implementation
|
159
159
|
|
160
|
-
* The code that manages your inputs (e.g. a Rails controller) instantiates a
|
160
|
+
* The code that manages your inputs (e.g. a Rails controller) instantiates a gateway
|
161
161
|
object
|
162
162
|
|
163
163
|
* The code that manages your inputs (e.g. a Rails controller) instantiates a use case actor
|
@@ -182,7 +182,7 @@ We satisfy the SAP by:
|
|
182
182
|
use_case_actor,
|
183
183
|
TargetActiveRecordClass.find(params[:id]),
|
184
184
|
strong_params,
|
185
|
-
|
185
|
+
gateway,
|
186
186
|
other_settings_hash
|
187
187
|
)
|
188
188
|
```
|
@@ -329,7 +329,7 @@ module MyBusinessDomain
|
|
329
329
|
module UseCases
|
330
330
|
class UserUpdatesNickname < CleanArchitecture::UseCases::AbstractUseCase
|
331
331
|
contract do
|
332
|
-
option :
|
332
|
+
option :my_gateway_object
|
333
333
|
|
334
334
|
params do
|
335
335
|
required(:user_id).filled(:id)
|
@@ -339,7 +339,7 @@ module MyBusinessDomain
|
|
339
339
|
rule(:nickname).validate(:not_already_taken)
|
340
340
|
|
341
341
|
register_macro(:not_already_taken) do
|
342
|
-
unless
|
342
|
+
unless my_gateway_object.username_is_available?(values[key_name])
|
343
343
|
key.failure('is already taken')
|
344
344
|
end
|
345
345
|
end
|
@@ -350,7 +350,7 @@ module MyBusinessDomain
|
|
350
350
|
|
351
351
|
def result
|
352
352
|
valid_params = yield result_of_validating_params
|
353
|
-
context(:
|
353
|
+
context(:my_gateway_object).result_of_updating_nickname(
|
354
354
|
valid_params[:id],
|
355
355
|
valid_params[:nickname]
|
356
356
|
)
|
@@ -404,7 +404,7 @@ module MyWebApp
|
|
404
404
|
def nickname_update_form
|
405
405
|
@nickname_update_form ||= NicknameUpdateForm.new(
|
406
406
|
params: params.permit(:user_id, :nickname),
|
407
|
-
context: {
|
407
|
+
context: { my_gateway_object: MyGateway.new }
|
408
408
|
)
|
409
409
|
end
|
410
410
|
end
|
@@ -436,7 +436,7 @@ module MyWebApp
|
|
436
436
|
|
437
437
|
def user_updates_nickname_parameters
|
438
438
|
MyBusinessDomain::UseCases::UserUpdatesNickname.parameters(
|
439
|
-
context: {
|
439
|
+
context: { my_gateway_object: MyGateway.new },
|
440
440
|
user_id: params[:user_id],
|
441
441
|
nickname: params[:nickname]
|
442
442
|
)
|
@@ -451,7 +451,7 @@ Elements of contracts can be shared amongst use cases, this can be very helpful
|
|
451
451
|
module MyBusinessDomain
|
452
452
|
module UseCases
|
453
453
|
class SharedContract < CleanArchitecture::UseCases::Contract
|
454
|
-
option :
|
454
|
+
option :my_gateway_object
|
455
455
|
|
456
456
|
register_macro(:not_already_taken?) do
|
457
457
|
unless not_already_taken?(values[key_name])
|
@@ -462,7 +462,7 @@ module MyBusinessDomain
|
|
462
462
|
private
|
463
463
|
|
464
464
|
def not_already_taken?(username)
|
465
|
-
|
465
|
+
my_gateway_object.username_is_available?(values[key_name])
|
466
466
|
end
|
467
467
|
end
|
468
468
|
end
|
@@ -476,7 +476,7 @@ module MyBusinessDomain
|
|
476
476
|
module UseCases
|
477
477
|
class UserUpdatesNickname < CleanArchitecture::UseCases::AbstractUseCase
|
478
478
|
contract(SharedContract) do
|
479
|
-
option :
|
479
|
+
option :my_gateway_object
|
480
480
|
|
481
481
|
params do
|
482
482
|
required(:user_id).filled(:id)
|
@@ -517,7 +517,7 @@ end
|
|
517
517
|
|
518
518
|
### `#context`
|
519
519
|
|
520
|
-
Any context variables defined as `option`'s in your use case contract have to be specified whenever creating an instance of the parameter objects for your use case. In practice this means you can't accidentally forget to pass in say a
|
520
|
+
Any context variables defined as `option`'s in your use case contract have to be specified whenever creating an instance of the parameter objects for your use case. In practice this means you can't accidentally forget to pass in say a gateway object / repository / factory / etc.
|
521
521
|
|
522
522
|
These context variables can be used within the use case using the `context` method:
|
523
523
|
|
@@ -526,7 +526,7 @@ module MyBusinessDomain
|
|
526
526
|
module UseCases
|
527
527
|
class UserUpdatesAge < CleanArchitecture::UseCases::AbstractUseCase
|
528
528
|
contract do
|
529
|
-
option :
|
529
|
+
option :required_gateway_object
|
530
530
|
|
531
531
|
params do
|
532
532
|
required(:user_id).filled(:int)
|
@@ -539,7 +539,7 @@ module MyBusinessDomain
|
|
539
539
|
def result
|
540
540
|
valid_params = yield result_of_validating_params
|
541
541
|
|
542
|
-
context(:
|
542
|
+
context(:required_gateway_object).update_user_age_result(
|
543
543
|
valid_params[:user_id],
|
544
544
|
valid_params[:age]
|
545
545
|
)
|
@@ -560,7 +560,7 @@ module MyBusinessDomain
|
|
560
560
|
module UseCases
|
561
561
|
class UserUpdatesChristmasWishlist < CleanArchitecture::UseCases::AbstractUseCase
|
562
562
|
contract do
|
563
|
-
option :
|
563
|
+
option :required_gateway_object
|
564
564
|
|
565
565
|
params do
|
566
566
|
required(:user_id).filled(:int)
|
@@ -579,7 +579,7 @@ module MyBusinessDomain
|
|
579
579
|
return fail_with_error_message('Uh oh, Santa has already left the North Pole!')
|
580
580
|
end
|
581
581
|
|
582
|
-
context(:
|
582
|
+
context(:required_gateway_object).change_most_wanted_gift(user_id, most_wanted_gift)
|
583
583
|
end
|
584
584
|
end
|
585
585
|
end
|
data/clean-architecture.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_dependency 'dry-struct'
|
27
27
|
spec.add_dependency 'dry-types'
|
28
28
|
spec.add_dependency 'dry-validation', '>= 1.0.0'
|
29
|
-
spec.add_dependency 'duckface-interfaces'
|
29
|
+
spec.add_dependency 'duckface-interfaces'
|
30
30
|
spec.add_dependency 'sorbet-runtime'
|
31
31
|
|
32
32
|
spec.add_development_dependency 'bundler'
|
@@ -7,16 +7,16 @@ require 'clean_architecture/interfaces/authorization_parameters'
|
|
7
7
|
module CleanArchitecture
|
8
8
|
module Entities
|
9
9
|
class TargetedParameters
|
10
|
-
attr_reader :actor, :extra_parameters_hash, :
|
10
|
+
attr_reader :actor, :extra_parameters_hash, :gateway, :target, :settings
|
11
11
|
|
12
12
|
implements_interface Interfaces::TargetedParameters
|
13
13
|
implements_interface Interfaces::AuthorizationParameters
|
14
14
|
|
15
|
-
def initialize(actor, target, extra_parameters_hash,
|
15
|
+
def initialize(actor, target, extra_parameters_hash, gateway, settings)
|
16
16
|
@actor = actor
|
17
17
|
@target = target
|
18
18
|
@extra_parameters_hash = extra_parameters_hash
|
19
|
-
@
|
19
|
+
@gateway = gateway
|
20
20
|
@settings = settings
|
21
21
|
end
|
22
22
|
end
|
@@ -6,14 +6,14 @@ require 'clean_architecture/interfaces/base_parameters'
|
|
6
6
|
module CleanArchitecture
|
7
7
|
module Entities
|
8
8
|
class UntargetedParameters
|
9
|
-
attr_reader :actor, :extra_parameters_hash, :
|
9
|
+
attr_reader :actor, :extra_parameters_hash, :gateway, :settings
|
10
10
|
|
11
11
|
implements_interface Interfaces::BaseParameters
|
12
12
|
|
13
|
-
def initialize(actor, extra_parameters_hash,
|
13
|
+
def initialize(actor, extra_parameters_hash, gateway, settings)
|
14
14
|
@actor = actor
|
15
15
|
@extra_parameters_hash = extra_parameters_hash
|
16
|
-
@
|
16
|
+
@gateway = gateway
|
17
17
|
@settings = settings
|
18
18
|
end
|
19
19
|
end
|
@@ -195,7 +195,7 @@
|
|
195
195
|
# wrong constant name define_attribute_method
|
196
196
|
# wrong constant name define_attribute_methods
|
197
197
|
# wrong constant name undefine_attribute_methods
|
198
|
-
# undefined method `initialize<defaultArg>1' for class `#<Class:
|
198
|
+
# undefined method `initialize<defaultArg>1' for class `#<Class:0x00007ff444bf9218>'
|
199
199
|
# wrong constant name <Class:AttributeMethodMatch>
|
200
200
|
# wrong constant name initialize<defaultArg>1
|
201
201
|
# wrong constant name initialize
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clean-architecture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bellroy Tech Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
117
|
+
version: '0'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: sorbet-runtime
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|