service_pattern 0.0.1 → 0.0.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6787a4f53bfdd57a07123e7eced76fdce0857cd
|
4
|
+
data.tar.gz: 1dede4fdc6bfcd28b8fef48927f8d1362c0a0dfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1de0f2175621e1ab35333e41ce768bb0b44bc92468b0c5266faee84658bff910fa1fdceb766dcfe649b16a4711ced4c34b40569e9602c847d6706ac72f6b05f0
|
7
|
+
data.tar.gz: 5332d4b8173004adee2ba1e6061e793cf3c7ee39cee66b2cac2df390218260c63dddbd5204903e545b7622d7061e4dd799768e26dafc7630773389133a28cc0b
|
@@ -0,0 +1 @@
|
|
1
|
+
class ServicePattern::CantExecuteError < RuntimeError; end
|
@@ -3,14 +3,27 @@ class ServicePattern::Service
|
|
3
3
|
service = new(*args)
|
4
4
|
|
5
5
|
begin
|
6
|
-
|
6
|
+
can_execute_response = service.can_execute?
|
7
|
+
|
8
|
+
puts "can_execute_response: #{can_execute_response.success?} (#{can_execute_response.errors})"
|
9
|
+
|
10
|
+
return can_execute_response unless can_execute_response.success?
|
11
|
+
service.execute!
|
7
12
|
rescue => e
|
8
|
-
ServicePattern::
|
13
|
+
ServicePattern::Response.new(errors: ["#{e.class.name}: #{e.message}"], success: false)
|
9
14
|
end
|
10
15
|
end
|
11
16
|
|
12
17
|
def self.execute!(*args)
|
13
|
-
new(*args)
|
18
|
+
service = new(*args)
|
19
|
+
|
20
|
+
can_execute_response = service.can_execute?
|
21
|
+
raise ServicePattern::CantExecuteError, can_execute_response.errors.join(". ") unless can_execute_response.success?
|
22
|
+
service.execute!
|
23
|
+
end
|
24
|
+
|
25
|
+
def can_execute?
|
26
|
+
ServicePattern::Response.new(success: true)
|
14
27
|
end
|
15
28
|
|
16
29
|
def execute!(*_args)
|
data/lib/service_pattern.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module ServicePattern
|
2
2
|
path = "#{File.dirname(__FILE__)}/service_pattern"
|
3
3
|
|
4
|
+
autoload :CantExecuteError, "#{path}/cant_execute_error"
|
5
|
+
autoload :Response, "#{path}/response"
|
4
6
|
autoload :Service, "#{path}/service"
|
5
|
-
autoload :ServiceResponse, "#{path}/service_response"
|
6
7
|
end
|
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_pattern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 4.0.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 4.0.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: sqlite3
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
11
|
+
date: 2017-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
41
13
|
description: ServicePattern for Ruby on Rails.
|
42
14
|
email:
|
43
15
|
- kaspernj@gmail.com
|
@@ -49,8 +21,9 @@ files:
|
|
49
21
|
- README.md
|
50
22
|
- Rakefile
|
51
23
|
- lib/service_pattern.rb
|
24
|
+
- lib/service_pattern/cant_execute_error.rb
|
25
|
+
- lib/service_pattern/response.rb
|
52
26
|
- lib/service_pattern/service.rb
|
53
|
-
- lib/service_pattern/service_response.rb
|
54
27
|
- lib/service_pattern/version.rb
|
55
28
|
- lib/tasks/service_pattern_tasks.rake
|
56
29
|
homepage: https://www.github.com/kaspernj/service_pattern
|