service_caller 1.2.0 → 1.2.2
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 +18 -15
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 637d2981aeedabbf0cfe06a9632d88c011ec53a359c6648415687182535729e9
|
4
|
+
data.tar.gz: 2ac6b5d4ff6ef50ef3f0ad2545ca1ecda712bc4f4ab9341683a160079d6a6dd9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bedde0a1add2a5ee07d28acb8ced09eab84572628db34d3f0cc313488ead97e3981b4345a4d196c9df10acd92814b70a6902e2a6b295b74622bde22f38fe354f
|
7
|
+
data.tar.gz: 2e6193f377f44a0257cd9ad8fcdda2af8c6339f0c793c21d3ab5d43248bc780019523572bfa1e5785db02c49f39ee70bf3cc57d43f555e4221e02df0732831f5
|
data/README.md
CHANGED
@@ -4,8 +4,8 @@
|
|
4
4
|
1. Add `service_caller` in your app's `Gemfile`.
|
5
5
|
|
6
6
|
``` ruby
|
7
|
-
# ruby version 2.7+ or later
|
8
|
-
gem 'service_caller', '~> 1.2.
|
7
|
+
# ruby version 2.7+, 3.0+ or later
|
8
|
+
gem 'service_caller', '~> 1.2.x'
|
9
9
|
# ruby version 2.6+ or eariler
|
10
10
|
gem 'service_caller', '~> 1.1.0'
|
11
11
|
```
|
@@ -30,12 +30,14 @@ $ bundle update service_caller
|
|
30
30
|
| Ruby Version | Rails Verision | Service Caller Version |
|
31
31
|
| - | - | - |
|
32
32
|
| 2.6 or eariler | 5.x | 1.1.0 |
|
33
|
-
| 2.7, 3.0 later | 6.x | 1.2.
|
33
|
+
| 2.7, 3.0+ or later | 6.x / 7.x / 8.x | 1.2.x |
|
34
34
|
|
35
35
|
## Usage
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
### Define service & inherit from `ServiceCaller`.
|
38
|
+
|
39
|
+
* **For ruby 2.6 or earlier** (ruby 2.7 may show deprecated warning message)
|
40
|
+
|
39
41
|
```ruby
|
40
42
|
class [Custom Service] < ServiceCaller
|
41
43
|
def initialize(*args)
|
@@ -50,7 +52,8 @@ class [Custom Service] < ServiceCaller
|
|
50
52
|
end
|
51
53
|
end
|
52
54
|
```
|
53
|
-
|
55
|
+
* **For ruby 2.7 or ruby 3.0**
|
56
|
+
|
54
57
|
``` ruby
|
55
58
|
class [Custom Service] < ServiceCaller
|
56
59
|
def initialize(*args, **hsh)
|
@@ -76,18 +79,18 @@ end
|
|
76
79
|
service = [Custom Service].call(*args, **hsh)
|
77
80
|
```
|
78
81
|
|
79
|
-
* check if success
|
82
|
+
* Simply check if service is success or failed.
|
80
83
|
```ruby
|
81
|
-
service.success?
|
82
|
-
service.failed?
|
84
|
+
service.success? # success => true / failed => false
|
85
|
+
service.failed? # failed => true / success => false
|
83
86
|
```
|
84
87
|
|
85
|
-
*
|
88
|
+
* Get success result information if service is success.
|
86
89
|
```ruby
|
87
90
|
service.result
|
88
91
|
```
|
89
92
|
|
90
|
-
*
|
93
|
+
* Get error information if service is failed.
|
91
94
|
```ruby
|
92
95
|
service.error
|
93
96
|
```
|
@@ -118,14 +121,14 @@ end
|
|
118
121
|
|
119
122
|
# Call the BMI Service
|
120
123
|
|
121
|
-
body_insight = {height: 1.80, weight: 73}
|
124
|
+
body_insight = { height: 1.80, weight: 73 }
|
122
125
|
bmi = CalBmi.call('william', **body_insight)
|
123
126
|
|
124
127
|
bmi.success? # it will show the caller is success or failed
|
125
128
|
bmi.result # it will show you => william's BMI is 22.53
|
126
129
|
|
127
130
|
bmi = CalBmi.call('', **body_insight)
|
128
|
-
bmi.error
|
129
|
-
bmi.error.key
|
130
|
-
bmi.error.error_obj #
|
131
|
+
bmi.error # if failed, the service will raise the custom error => #<ServiceError: member_name_not_found>
|
132
|
+
bmi.error.key # :member_name_not_found
|
133
|
+
bmi.error.error_obj # {:error_msg=>"not enter the name"}
|
131
134
|
```
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: service_caller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JiaRou Lee
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: basic implement of service object
|
14
13
|
email: laura34963@kdanmobile.com
|
@@ -25,8 +24,9 @@ files:
|
|
25
24
|
homepage: https://github.com/kdan-mobile-software-ltd/service_caller
|
26
25
|
licenses:
|
27
26
|
- MIT
|
28
|
-
metadata:
|
29
|
-
|
27
|
+
metadata:
|
28
|
+
source_code_uri: https://github.com/kdan-mobile-software-ltd/service_caller
|
29
|
+
changelog_uri: https://github.com/kdan-mobile-software-ltd/service_caller/blob/master/CHANGELOG.md
|
30
30
|
rdoc_options:
|
31
31
|
- "--charset=UTF-8"
|
32
32
|
require_paths:
|
@@ -42,8 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
46
|
-
signing_key:
|
45
|
+
rubygems_version: 3.6.9
|
47
46
|
specification_version: 4
|
48
47
|
summary: Ruby Service Basic Class
|
49
48
|
test_files: []
|