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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ba006abbb363e6e905b04bc28d034d3ce3500a1972569796b3a4535d399f2a5
4
- data.tar.gz: d6843c0cba4fcfe46ea34dc4b7e650a9356566a4e4c6ce2703234a3f44b88ca9
3
+ metadata.gz: cdb56345fc9435ba6661951aa8d3cc5176022c2767881b340b6551c94c8e4caa
4
+ data.tar.gz: f9fc3f3ae0262dfa6c0ff58505cce750070074bdf9cb8d52ed826695ec3eb46e
5
5
  SHA512:
6
- metadata.gz: 4f0069948ebd6189ab2915d74b5a5ef299a61628082b58f8913ec5224746322d4f354542b4ece26d8672d58b38668651bc95b1ab660b2e4cf55bbbb0d2130393
7
- data.tar.gz: 1c5dc20138d2d26a3e3b2e93d292861fd981c4fe7afc2a984dc09e48fe46dfd51ac71bd7e9030507a5d4998ff93a9c03c897173a96ef594f2aa410fb524a6b64
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.execute
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.execute
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(*_args)
59
- raise NoMethodError, "You should implement the `execute` method on your service"
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)
@@ -1,3 +1,3 @@
1
1
  module ServicePattern
2
- VERSION = "0.0.8".freeze
2
+ VERSION = "1.0.0".freeze
3
3
  end
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.8
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: 2020-09-03 00:00:00.000000000 Z
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: '0'
42
+ version: 2.5.0
43
43
  required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="