service_pattern 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -0
- data/lib/service_pattern/service.rb +0 -3
- data/lib/service_pattern/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d475628b9f7d75075a9069a45e64849402685d7
|
4
|
+
data.tar.gz: 06c1e5aa4f668b258a753503c74edaaa30dcf858
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec2869750e398a401e478bc755f8d1a351f1264ffa5be853e5e79bf0441bc23f11bf4f0abd7dd5446ed222a16e7eda9148d049df013d0a0ffac7557d6c8e3ed6
|
7
|
+
data.tar.gz: a77b1ad0406d8693ab31397ba307b306f627120baf0dd9ee09ca7eccbd68987b72a9b53371c0aa965797275b00bab5ef1004c3ba0dee4e80ef62d67c0c4f7a9c
|
data/README.md
CHANGED
@@ -12,5 +12,32 @@ Add this line to your application's Gemfile:
|
|
12
12
|
gem "service_pattern"
|
13
13
|
```
|
14
14
|
|
15
|
+
Create an application service that your other services will enherit from in "app/services/application_service":
|
16
|
+
```ruby
|
17
|
+
class ApplicationService < ServicePattern::Service
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
Create your first service in "app/services/users/activator_service":
|
22
|
+
```ruby
|
23
|
+
class Users::ActivatorService < ApplicationService
|
24
|
+
def execute!
|
25
|
+
User.all.find_each(&:activate!)
|
26
|
+
ServicePattern::Response.new(success: true)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
Then call it like this:
|
32
|
+
```ruby
|
33
|
+
response = Users::ActivatorService.()
|
34
|
+
|
35
|
+
if response.success?
|
36
|
+
puts "Wee"
|
37
|
+
else
|
38
|
+
puts "Errors: #{result.errors.join(". ")}"
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
15
42
|
## License
|
16
43
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -4,9 +4,6 @@ class ServicePattern::Service
|
|
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
7
|
return can_execute_response unless can_execute_response.success?
|
11
8
|
service.execute!
|
12
9
|
rescue => e
|
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: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ServicePattern for Ruby on Rails.
|
14
14
|
email:
|