clean-architecture 0.0.1 → 0.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/CHANGELOG.md +8 -0
- data/README.md +67 -0
- data/lib/clean_architecture/all.rb +1 -1
- data/lib/clean_architecture/serializers/all.rb +1 -0
- data/lib/clean_architecture/serializers/success_payload.rb +26 -0
- data/lib/clean_architecture/strategies/actor_gets_authorized_then_does_work.rb +1 -1
- data/lib/clean_architecture/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0355fa965f9398c91c72c743a402a76fd6d368f7
|
4
|
+
data.tar.gz: 1ffe824aa7cfb103368ec19def56b71303a5d03e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2bff0f8f22af994574f97bf16c35012aebf8ef6f8476561068e6d4b7fac5fb04e68af540e7c0651056a4f1ed845e10f828043c957d02a1cf7d18b1b2845811e
|
7
|
+
data.tar.gz: e119b8dc2e8e9bc42684839bb5a2c5a13fc5fe09db8b08160e17f7e02d0cd0f510f318d6ef808355b25aee974fb57b7ef65e449d4b3fe849034bc7342a35dbcb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -15,3 +15,70 @@ And then execute:
|
|
15
15
|
|
16
16
|
$ bundle install
|
17
17
|
$ bundle binstubs clean-architecture
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
The intention of this gem is to help you build applications that are built from the use case down,
|
22
|
+
and decisions about I/O can be deferred until the last possible moment. It relies heavily on the
|
23
|
+
[duckface-interfaces](https://github.com/samuelgiles/duckface) gem to enforce interface
|
24
|
+
implementation.
|
25
|
+
|
26
|
+
### Use cases as an organisational principle
|
27
|
+
|
28
|
+
Uncle Bob suggests that your source code organisation should allow developers to easily find a
|
29
|
+
listing of all use cases your application provides. Here's an example of how this might look in a
|
30
|
+
Rails application.
|
31
|
+
|
32
|
+
```
|
33
|
+
- lib
|
34
|
+
- my_banking_application
|
35
|
+
- use_cases
|
36
|
+
- retail_customer_opens_bank_account.rb
|
37
|
+
- retail_customer_makes_a_deposit.rb
|
38
|
+
- ...
|
39
|
+
```
|
40
|
+
|
41
|
+
### Clean architecture principles
|
42
|
+
|
43
|
+
* The code that manages your inputs (e.g. a Rails controller) instantiates a persistence layer
|
44
|
+
object
|
45
|
+
- Suggest: a class that implements both the `Persistence` interface and your own persistence
|
46
|
+
interface
|
47
|
+
|
48
|
+
```
|
49
|
+
persistence = ActiveRecordPersistence.new
|
50
|
+
```
|
51
|
+
|
52
|
+
* The code that manages your inputs (e.g. a Rails controller) instantiates a use case actor
|
53
|
+
object
|
54
|
+
- Suggest: a class that implements the `UseCaseActor` interface
|
55
|
+
|
56
|
+
```
|
57
|
+
use_case_actor = MyUseCaseActorAdapter.new(devise_current_user)
|
58
|
+
```
|
59
|
+
|
60
|
+
* The code that manages your inputs (e.g. a Rails controller) instantiates a use case input port
|
61
|
+
object
|
62
|
+
- Suggest: a class that implements the `BaseParameters` interface
|
63
|
+
- Suggest: implement the `AuthorizationParameters` interface if you want to make authorization
|
64
|
+
part of your use case logic
|
65
|
+
- Suggest: implement the `TargetedParameters` if your use case operates on a single object
|
66
|
+
- Suggest: use the `TargetedParameters` entity for an out-of-the-box class that gives you all of
|
67
|
+
these
|
68
|
+
|
69
|
+
```
|
70
|
+
input_port = CleanArchitecture::Entities::TargetedParameters.new(
|
71
|
+
use_case_actor,
|
72
|
+
TargetActiveRecordClass.find(params[:id]),
|
73
|
+
strong_params,
|
74
|
+
persistence,
|
75
|
+
other_settings_hash
|
76
|
+
)
|
77
|
+
```
|
78
|
+
|
79
|
+
* The code that manages your inputs (e.g. a Rails controller) instantiates a use case object
|
80
|
+
- Suggest: a class that implements the `UseCase` interface
|
81
|
+
|
82
|
+
```
|
83
|
+
use_case = MyBankingApplication::UseCases::RetailCustomerMakesADeposit.new(input_port)
|
84
|
+
```
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
# THIS FILE IS AUTOGENERATED AND SHOULD NOT BE MANUALLY MODIFIED
|
4
4
|
|
5
|
-
require 'clean_architecture/interfaces/all'
|
6
5
|
require 'clean_architecture/entities/all'
|
6
|
+
require 'clean_architecture/interfaces/all'
|
7
7
|
require 'clean_architecture/queries/all'
|
8
8
|
require 'clean_architecture/serializers/all'
|
9
9
|
require 'clean_architecture/strategies/all'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'duckface'
|
4
|
+
|
5
|
+
module CleanArchitecture
|
6
|
+
module Serializers
|
7
|
+
class SuccessPayload
|
8
|
+
implements_interface CleanArchitecture::Interfaces::SuccessPayload
|
9
|
+
|
10
|
+
attr_reader :version
|
11
|
+
|
12
|
+
def initialize(use_case_target, version)
|
13
|
+
@use_case_target = use_case_target
|
14
|
+
@version = version
|
15
|
+
end
|
16
|
+
|
17
|
+
def data_hash
|
18
|
+
{
|
19
|
+
type: @use_case_target.type_name,
|
20
|
+
id: @use_case_target.identifier,
|
21
|
+
attributes: @use_case_target.attribute_hash
|
22
|
+
}.compact
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
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: 0.0.
|
4
|
+
version: 0.0.3
|
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: 2018-
|
11
|
+
date: 2018-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-matcher
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/clean_architecture/serializers/all.rb
|
141
141
|
- lib/clean_architecture/serializers/html_response_from_result.rb
|
142
142
|
- lib/clean_architecture/serializers/json_response_from_result.rb
|
143
|
+
- lib/clean_architecture/serializers/success_payload.rb
|
143
144
|
- lib/clean_architecture/strategies/actor_gets_authorized_then_does_work.rb
|
144
145
|
- lib/clean_architecture/strategies/all.rb
|
145
146
|
- lib/clean_architecture/strategies/with_audit_trail.rb
|