service_pattern 0.0.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/service_pattern/service.rb +13 -10
- data/lib/service_pattern/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdb56345fc9435ba6661951aa8d3cc5176022c2767881b340b6551c94c8e4caa
|
4
|
+
data.tar.gz: f9fc3f3ae0262dfa6c0ff58505cce750070074bdf9cb8d52ed826695ec3eb46e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5466648e3d09f9add63cd3205a94f4f27e9d732a322e84eba8982f16d8d448d745669fcdbd38ddb04a5ac29663491129ef7ef315589b37c5a5e43fe118f94563
|
7
|
+
data.tar.gz: b1dfe83d17699a4eb998a7a85614e735979443c2baedd27d51d65549a2896e4377b65c150c6b0a55889d194d6d25c7212fe6ea90a8db31ab62f9a23393d31b4d
|
@@ -6,7 +6,7 @@ class ServicePattern::Service
|
|
6
6
|
can_execute_response = service.can_execute?
|
7
7
|
ServicePattern::Service.fail!(can_execute_response.errors) unless can_execute_response.success?
|
8
8
|
|
9
|
-
service.
|
9
|
+
service.perform
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.call(*args, &blk)
|
@@ -15,20 +15,14 @@ class ServicePattern::Service
|
|
15
15
|
|
16
16
|
def self.execute(*args, &blk)
|
17
17
|
service = new(*args, &blk)
|
18
|
-
|
19
|
-
can_execute_response = service.can_execute?
|
20
|
-
return can_execute_response unless can_execute_response.success?
|
21
|
-
|
22
18
|
service.execute
|
23
|
-
rescue ServicePattern::FailedError => e
|
24
|
-
ServicePattern::Response.new(errors: e.errors)
|
25
19
|
end
|
26
20
|
|
27
21
|
def self.execute!(*args, &blk)
|
28
22
|
service = new(*args, &blk)
|
29
23
|
can_execute_response = service.can_execute?
|
30
24
|
ServicePattern::Service.fail!(can_execute_response.errors) unless can_execute_response.success?
|
31
|
-
response = service.
|
25
|
+
response = service.perform
|
32
26
|
ServicePattern::Service.fail!(response.errors) unless response.success?
|
33
27
|
response.result
|
34
28
|
end
|
@@ -55,8 +49,17 @@ class ServicePattern::Service
|
|
55
49
|
succeed!
|
56
50
|
end
|
57
51
|
|
58
|
-
def execute
|
59
|
-
|
52
|
+
def execute
|
53
|
+
can_execute_response = can_execute?
|
54
|
+
return can_execute_response unless can_execute_response.success?
|
55
|
+
|
56
|
+
perform
|
57
|
+
rescue ServicePattern::FailedError => e
|
58
|
+
ServicePattern::Response.new(errors: e.errors)
|
59
|
+
end
|
60
|
+
|
61
|
+
def perform(*_args)
|
62
|
+
raise NoMethodError, "You should implement the `perform` method on your service"
|
60
63
|
end
|
61
64
|
|
62
65
|
def fail!(errors, type: nil)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_pattern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ServicePattern for Ruby on Rails.
|
14
14
|
email:
|
@@ -39,7 +39,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
39
|
requirements:
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 2.5.0
|
43
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|