clean-architecture 0.2.0 → 1.0.0
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/Gemfile.lock +1 -1
- data/lib/clean_architecture/all.rb +2 -0
- data/lib/clean_architecture/checks/all.rb +5 -0
- data/lib/clean_architecture/checks/authorization.rb +35 -0
- data/lib/clean_architecture/commands/all.rb +5 -0
- data/lib/clean_architecture/commands/write_use_case_audit_trail.rb +23 -0
- data/lib/clean_architecture/entities/failure_details.rb +1 -1
- data/lib/clean_architecture/entities/use_case_history_entry.rb +5 -4
- data/lib/clean_architecture/interfaces/all.rb +0 -3
- data/lib/clean_architecture/strategies/all.rb +0 -2
- data/lib/clean_architecture/version.rb +1 -1
- metadata +5 -6
- data/lib/clean_architecture/interfaces/authorization_check.rb +0 -15
- data/lib/clean_architecture/interfaces/command.rb +0 -23
- data/lib/clean_architecture/interfaces/strategy.rb +0 -17
- data/lib/clean_architecture/strategies/actor_gets_authorized_then_does_work.rb +0 -38
- data/lib/clean_architecture/strategies/with_audit_trail.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d751cba3aff6904c1fc224d28039d479ea698805
|
4
|
+
data.tar.gz: 37182b20aab7f39b7caf92aae13db1efb186ba10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f003370b9134dcc89007f48a3d754c4e55603aa191a12ad599107f46cc2d91088cad2d4c2f6accf61ebe87819126d289f645f0e0858dee418ca839838b93a6b7
|
7
|
+
data.tar.gz: 5479aaa78c7e438f581af8f8481fa025f40b6705b55181aae59389492f74d927d63a3e709b48aa7cd3377953808075968c4198591ca6697de6cc1978931c8847
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
1.0.0
|
2
|
+
|
3
|
+
* Remove strategy and command interfaces
|
4
|
+
* Turn Authorization into a virtual class rather than an interface
|
5
|
+
* Remove ActorGetsAuthorizedThenDoesWork in favour of having the Authorization virtual class
|
6
|
+
return a result type (use .bind in the client)
|
7
|
+
* Change WithAuditTrail to WriteUseCaseAuditTrail command with a result
|
8
|
+
|
1
9
|
0.2.0
|
2
10
|
|
3
11
|
* Add Entities::FailureDetails and support for it in the various Serializers
|
data/Gemfile.lock
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# THIS FILE IS AUTOGENERATED AND SHOULD NOT BE MANUALLY MODIFIED
|
4
4
|
|
5
5
|
require 'clean_architecture/adapters/all'
|
6
|
+
require 'clean_architecture/checks/all'
|
7
|
+
require 'clean_architecture/commands/all'
|
6
8
|
require 'clean_architecture/entities/all'
|
7
9
|
require 'clean_architecture/interfaces/all'
|
8
10
|
require 'clean_architecture/matchers/all'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'dry/monads/all'
|
4
|
+
require 'clean_architecture/entities/failure_details'
|
5
|
+
|
6
|
+
module CleanArchitecture
|
7
|
+
module Checks
|
8
|
+
class Authorization
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def result
|
12
|
+
if authorized?
|
13
|
+
Dry::Monads::Success(true)
|
14
|
+
else
|
15
|
+
failure_details = Entities::FailureDetails.new(
|
16
|
+
message: failure_message,
|
17
|
+
other_properties: {},
|
18
|
+
type: 'unauthorized'
|
19
|
+
)
|
20
|
+
Dry::Monads::Failure(failure_details)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def failure_message
|
27
|
+
'Unauthorized'
|
28
|
+
end
|
29
|
+
|
30
|
+
def authorized?
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'clean_architecture/entities/use_case_history_entry'
|
4
|
+
require 'duckface'
|
5
|
+
|
6
|
+
module CleanArchitecture
|
7
|
+
module Commands
|
8
|
+
class WriteUseCaseAuditTrail
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def initialize(use_case_target)
|
12
|
+
@use_case_target = use_case_target
|
13
|
+
end
|
14
|
+
|
15
|
+
def result
|
16
|
+
@result ||= begin
|
17
|
+
entry = Entities::UseCaseHistoryEntry.new(@use_case_target)
|
18
|
+
parameters.persistence.create_use_case_history_entry(entry)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -12,11 +12,12 @@ module CleanArchitecture
|
|
12
12
|
implements_interface Interfaces::UseCaseHistoryEntry
|
13
13
|
extend Forwardable
|
14
14
|
|
15
|
-
def initialize(
|
16
|
-
@
|
17
|
-
@use_case_parameters = use_case_parameters
|
18
|
-
@use_case_result = use_case_result
|
15
|
+
def initialize(use_case, use_case_target)
|
16
|
+
@use_case = use_case
|
19
17
|
@use_case_target = use_case_target
|
18
|
+
@use_case_class = @use_case.class
|
19
|
+
@use_case_parameters = @use_case.parameters
|
20
|
+
@use_case_result = @use_case.result
|
20
21
|
end
|
21
22
|
|
22
23
|
def extra_parameters_hash
|
@@ -2,13 +2,10 @@
|
|
2
2
|
|
3
3
|
# THIS FILE IS AUTOGENERATED AND SHOULD NOT BE MANUALLY MODIFIED
|
4
4
|
|
5
|
-
require 'clean_architecture/interfaces/authorization_check'
|
6
5
|
require 'clean_architecture/interfaces/authorization_parameters'
|
7
6
|
require 'clean_architecture/interfaces/base_parameters'
|
8
|
-
require 'clean_architecture/interfaces/command'
|
9
7
|
require 'clean_architecture/interfaces/jsonable'
|
10
8
|
require 'clean_architecture/interfaces/persistence'
|
11
|
-
require 'clean_architecture/interfaces/strategy'
|
12
9
|
require 'clean_architecture/interfaces/success_payload'
|
13
10
|
require 'clean_architecture/interfaces/targeted_parameters'
|
14
11
|
require 'clean_architecture/interfaces/use_case'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clean-architecture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bellroy Tech Team
|
@@ -148,19 +148,20 @@ files:
|
|
148
148
|
- lib/clean_architecture/adapters/all.rb
|
149
149
|
- lib/clean_architecture/adapters/attribute_hash_base.rb
|
150
150
|
- lib/clean_architecture/all.rb
|
151
|
+
- lib/clean_architecture/checks/all.rb
|
152
|
+
- lib/clean_architecture/checks/authorization.rb
|
153
|
+
- lib/clean_architecture/commands/all.rb
|
154
|
+
- lib/clean_architecture/commands/write_use_case_audit_trail.rb
|
151
155
|
- lib/clean_architecture/entities/all.rb
|
152
156
|
- lib/clean_architecture/entities/failure_details.rb
|
153
157
|
- lib/clean_architecture/entities/targeted_parameters.rb
|
154
158
|
- lib/clean_architecture/entities/untargeted_parameters.rb
|
155
159
|
- lib/clean_architecture/entities/use_case_history_entry.rb
|
156
160
|
- lib/clean_architecture/interfaces/all.rb
|
157
|
-
- lib/clean_architecture/interfaces/authorization_check.rb
|
158
161
|
- lib/clean_architecture/interfaces/authorization_parameters.rb
|
159
162
|
- lib/clean_architecture/interfaces/base_parameters.rb
|
160
|
-
- lib/clean_architecture/interfaces/command.rb
|
161
163
|
- lib/clean_architecture/interfaces/jsonable.rb
|
162
164
|
- lib/clean_architecture/interfaces/persistence.rb
|
163
|
-
- lib/clean_architecture/interfaces/strategy.rb
|
164
165
|
- lib/clean_architecture/interfaces/success_payload.rb
|
165
166
|
- lib/clean_architecture/interfaces/targeted_parameters.rb
|
166
167
|
- lib/clean_architecture/interfaces/use_case.rb
|
@@ -176,9 +177,7 @@ files:
|
|
176
177
|
- lib/clean_architecture/serializers/html_response_from_result.rb
|
177
178
|
- lib/clean_architecture/serializers/json_response_from_result.rb
|
178
179
|
- lib/clean_architecture/serializers/success_payload.rb
|
179
|
-
- lib/clean_architecture/strategies/actor_gets_authorized_then_does_work.rb
|
180
180
|
- lib/clean_architecture/strategies/all.rb
|
181
|
-
- lib/clean_architecture/strategies/with_audit_trail.rb
|
182
181
|
- lib/clean_architecture/types.rb
|
183
182
|
- lib/clean_architecture/version.rb
|
184
183
|
homepage: https://bellroy.com
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'duckface'
|
4
|
-
|
5
|
-
module CleanArchitecture
|
6
|
-
module Interfaces
|
7
|
-
module Command
|
8
|
-
extend Duckface::ActsAsInterface
|
9
|
-
|
10
|
-
def initialize(_parameters)
|
11
|
-
raise NotImplementedError
|
12
|
-
end
|
13
|
-
|
14
|
-
def parameters
|
15
|
-
raise NotImplementedError
|
16
|
-
end
|
17
|
-
|
18
|
-
def result
|
19
|
-
raise NotImplementedError
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CleanArchitecture
|
4
|
-
module Interfaces
|
5
|
-
module Strategy
|
6
|
-
extend Duckface::ActsAsInterface
|
7
|
-
|
8
|
-
def parameters
|
9
|
-
raise NotImplementedError
|
10
|
-
end
|
11
|
-
|
12
|
-
def result
|
13
|
-
raise NotImplementedError
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'dry/monads/all'
|
4
|
-
require 'clean_architecture/entities/failure_details'
|
5
|
-
require 'clean_architecture/interfaces/strategy'
|
6
|
-
|
7
|
-
module CleanArchitecture
|
8
|
-
module Strategies
|
9
|
-
class ActorGetsAuthorizedThenDoesWork
|
10
|
-
extend Forwardable
|
11
|
-
|
12
|
-
implements_interface Interfaces::Strategy
|
13
|
-
|
14
|
-
def initialize(authorization_check, sub_strategy)
|
15
|
-
@authorization_check = authorization_check
|
16
|
-
@sub_strategy = sub_strategy
|
17
|
-
end
|
18
|
-
|
19
|
-
def_delegator :@sub_strategy, :parameters
|
20
|
-
|
21
|
-
UNAUTHORIZED_FAILURE_DETAILS = Entities::FailureDetails.new(
|
22
|
-
message: 'Unauthorized',
|
23
|
-
other_properties: {},
|
24
|
-
type: 'unauthorized'
|
25
|
-
)
|
26
|
-
|
27
|
-
def result
|
28
|
-
@result ||= begin
|
29
|
-
if @authorization_check.authorized?
|
30
|
-
@sub_strategy.result
|
31
|
-
else
|
32
|
-
Dry::Monads::Failure(UNAUTHORIZED_FAILURE_DETAILS)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'clean_architecture/entities/use_case_history_entry'
|
4
|
-
require 'clean_architecture/interfaces/strategy'
|
5
|
-
require 'duckface'
|
6
|
-
|
7
|
-
module CleanArchitecture
|
8
|
-
module Strategies
|
9
|
-
class WithAuditTrail
|
10
|
-
implements_interface Interfaces::Strategy
|
11
|
-
extend Forwardable
|
12
|
-
|
13
|
-
def initialize(use_case_class, sub_strategy, use_case_target)
|
14
|
-
@use_case_class = use_case_class
|
15
|
-
@sub_strategy = sub_strategy
|
16
|
-
@use_case_target = use_case_target
|
17
|
-
end
|
18
|
-
|
19
|
-
def result
|
20
|
-
@result ||= begin
|
21
|
-
strategy_result = @sub_strategy.result
|
22
|
-
entry = new_use_case_history_entry(strategy_result)
|
23
|
-
parameters.persistence.create_use_case_history_entry(entry)
|
24
|
-
strategy_result
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def_delegator :@sub_strategy, :parameters
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def new_use_case_history_entry(sub_strategy_result)
|
33
|
-
Entities::UseCaseHistoryEntry.new(
|
34
|
-
@use_case_class,
|
35
|
-
@sub_strategy.parameters,
|
36
|
-
sub_strategy_result,
|
37
|
-
@use_case_target
|
38
|
-
)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|