clean-architecture 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb6fbe1a9004389c1d14f8cbe72293825ffc8530
4
- data.tar.gz: 13838c48fd2f72411bd17afe06d7810832f95c41
3
+ metadata.gz: 0355fa965f9398c91c72c743a402a76fd6d368f7
4
+ data.tar.gz: 1ffe824aa7cfb103368ec19def56b71303a5d03e
5
5
  SHA512:
6
- metadata.gz: '084fbabf3a62f60fdc360535cd53e031892dfdcd784a1b8580edd471aa1b11d9e77b814c4ed7db6d52829fb2a854853e1967180ed3fd124fed9843e3000de509'
7
- data.tar.gz: b35ef32add448162a6595debb3b7ca74b79fb5625fbe8b82a353cd54a9116678111d7391f3047b237e2378f11fb709f1786a4c5c723c9b8e2a8cfe87f5a3352f
6
+ metadata.gz: f2bff0f8f22af994574f97bf16c35012aebf8ef6f8476561068e6d4b7fac5fb04e68af540e7c0651056a4f1ed845e10f828043c957d02a1cf7d18b1b2845811e
7
+ data.tar.gz: e119b8dc2e8e9bc42684839bb5a2c5a13fc5fe09db8b08160e17f7e02d0cd0f510f318d6ef808355b25aee974fb57b7ef65e449d4b3fe849034bc7342a35dbcb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ 0.0.3
2
+
3
+ * Fix require files
4
+
5
+ 0.0.2
6
+
7
+ * Add Serializers::SuccessPayload
8
+
1
9
  0.0.1
2
10
 
3
11
  * Initial release
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'
@@ -4,3 +4,4 @@
4
4
 
5
5
  require 'clean_architecture/serializers/html_response_from_result'
6
6
  require 'clean_architecture/serializers/json_response_from_result'
7
+ require 'clean_architecture/serializers/success_payload'
@@ -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
@@ -21,7 +21,7 @@ module CleanArchitecture
21
21
  if @authorization_check.authorized?
22
22
  @sub_strategy.result
23
23
  else
24
- Dry::Monads::Failure('Unauthorized: Invalid API key')
24
+ Dry::Monads::Failure('Unauthorized')
25
25
  end
26
26
  end
27
27
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CleanArchitecture
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.3'
5
5
  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.1
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-06-23 00:00:00.000000000 Z
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