rails_use_case 0.0.12 → 0.0.13
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/README.md +5 -3
- data/lib/rails/service.rb +2 -2
- data/lib/rails/use_case.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eb1a5ed5601e1c4e070962f4d19c2e35a4ea23980151fa35ec02c6328a2fd0d
|
4
|
+
data.tar.gz: 20821b8d657c535ee16ae2c920e1e93a8d0b21c384d99b25e5c986ff0914b0eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64c64c919a75d87bdea7a339fd9322c33b97a30b46bfa668a3eb970b3e542af9416176e5cc9783a0f133349648beb022983d66cafd30473f77708eb0de6a9963
|
7
|
+
data.tar.gz: 9f26874c317b868bd84c6232a2af3562bf54feddb4851552fbbccdc8294e38bdd2a89b420cdf387f623d1f5e361de9d24232a46b77d1dec13fb885a8bb1ab99d
|
data/README.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
# Rails Use Case gem
|
2
2
|
|
3
|
-
|
3
|
+
This gem introduces UseCases and Services to Rails which allow you to keep your Models and Controllers slim.
|
4
4
|
|
5
5
|
Read more: https://dev.to/phortx/pimp-your-rails-application-32d0
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
Clean Architecture suggests to put the business logic in UseCases which are classes, that contain reusable high
|
8
|
+
level business logic which otherwise would normally be located in the controller. UseCases are easy to read,
|
9
|
+
clean, reusable, testable and extendable.
|
10
|
+
Examples are: Place an item in the cart, create a new user or delete a comment.
|
9
11
|
|
10
12
|
The purpose of a Service is to contain low level non-domain code like communication with a API,
|
11
13
|
generating an export, upload via FTP or generating a PDF.
|
data/lib/rails/service.rb
CHANGED
@@ -38,7 +38,7 @@ module Rails
|
|
38
38
|
#
|
39
39
|
# @raise [RuntimeError] When no service_name is given
|
40
40
|
def initialize(service_name = nil)
|
41
|
-
raise NotImplementedError if
|
41
|
+
raise NotImplementedError if instance_of?(Service)
|
42
42
|
raise 'Please provide a service name!' if service_name.nil?
|
43
43
|
|
44
44
|
@service_name = service_name
|
@@ -67,7 +67,7 @@ module Rails
|
|
67
67
|
# Will setup the logger for logging to STDOUT. This can be useful for
|
68
68
|
# Heroku for example.
|
69
69
|
private def setup_stdout_logger
|
70
|
-
@logger = Logger.new(
|
70
|
+
@logger = Logger.new($stdout)
|
71
71
|
|
72
72
|
@logger.formatter = proc do |severity, datetime, progname, msg|
|
73
73
|
"[#{@service_name}] #{msg}"
|
data/lib/rails/use_case.rb
CHANGED
@@ -98,7 +98,7 @@ module Rails
|
|
98
98
|
fail!(code: opts[:code], message: opts[:message]) if name == :failure
|
99
99
|
|
100
100
|
# Run the lambda, when :do is set. Otherwise call the method.
|
101
|
-
next if opts[:do] ?
|
101
|
+
next if opts[:do] ? instance_exec(&opts[:do]) : send(name)
|
102
102
|
|
103
103
|
# result is false, so we have a failure.
|
104
104
|
fail! code: :step_false, message: "Step '#{name}' returned false"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_use_case
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Klein
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -195,7 +195,7 @@ homepage: https://github.com/phortx/rails-use-case
|
|
195
195
|
licenses:
|
196
196
|
- MIT
|
197
197
|
metadata: {}
|
198
|
-
post_install_message:
|
198
|
+
post_install_message:
|
199
199
|
rdoc_options: []
|
200
200
|
require_paths:
|
201
201
|
- lib
|
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
213
|
rubygems_version: 3.1.2
|
214
|
-
signing_key:
|
214
|
+
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: Rails UseCase and Service classes
|
217
217
|
test_files: []
|