Rails (API) app that shows different kinds of architecture (one per commit), and in the last one, how to use the Micro::Case gem to handle the application business logic.
fat controllers
to use cases
Rails (API) app that shows different kinds of architecture (one per commit), and in the last one, how to use the Micro::Case gem to handle the application business logic.
2.6.5
sqlite3
bin/setup
bin/rails test
Version | Description | Rubycritic Score |
---|---|---|
1 | Fat controller | 91.53 |
2 | Fat model, skinny controller | 87.45 |
3 | Concerns | 89.25 |
4 | Service objects | 92.55 |
4.1 | Service objects - Inheritance | 92.93 |
4.2 | Service objects - Inheritance overusing | 93.15 |
5 | Interactors | 96.36 |
6 | Domain objects | 94.71 |
7 | Use cases (Micro::Case) | 94.97 |
7.1 | Use cases - Dryer version | 95.24 |
7.2 | Use cases- Improving the SRP | 95.11 |
Hint: in any of the versions above, use bin/rails rubycritic
to see the full report result.
Use the use_cases
task. e.g:
bin/rails use_cases
# Lines:
# 11 ./app/models/user/register/step/serialize_as_json.rb
# 12 ./app/models/user/register/step/validate_password.rb
# 17 ./app/models/user/register/step/create_record.rb
# 19 ./app/models/user/register/step/normalize_params.rb
# 10 ./app/models/user/register/flow.rb
# 18 ./app/models/todo/list/add_item.rb
# 16 ./app/models/todo/list/complete_item.rb
# 14 ./app/models/todo/list/delete_item.rb
# 12 ./app/models/todo/list/fetch_items.rb
# 14 ./app/models/todo/list/find_item.rb
# 19 ./app/models/todo/list/update_item.rb
# 16 ./app/models/todo/list/activate_item.rb
# 21 ./app/models/todo/serialize.rb
# 199 total
#
# Files: 13
Note: This task will only be available in the branches with use cases (v7
, v7.1
, v7.2
).