response_callback 0.1.0 → 1.0.0
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 +44 -5
- data/lib/response_callback/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: d54b7d4c5d1c10e20ad6fc8e4405c3dd95f0d523
|
4
|
+
data.tar.gz: 7347b3420f9ac34ca31c8cf2963bebaa08b44e5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ada5f91ea6a259b52a80f2f572b5e53e3c63905c6859bf44f345a3f7da3c9a55881d0eaeda8968761bedcdc2b0b2aa6876d784c7e15dfbb43f3334f558ce4d2
|
7
|
+
data.tar.gz: 2bbdc4e1943593153fd0c6d43fe811faeb73fc8a9d7c07c02f4742c85b9ef348bf437df5aa05dc342cce2c3bafe15e646b298ad1373dec7e72fc864fe3f92778
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# ResponseCallback
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Response callback for command query separation.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,45 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
It can be used with just the callbacks.
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
class AClass
|
27
|
+
def self.a_complex_operation
|
28
|
+
complex stuff
|
29
|
+
yield ResponseCallback::Success.new
|
30
|
+
rescue => e
|
31
|
+
yield ResponseCallback::Fail.new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
AClass.a_complex_operation do |response|
|
36
|
+
response.on_success do
|
37
|
+
deal_with_success
|
38
|
+
end
|
39
|
+
response.on_fail do
|
40
|
+
deal_with_failure
|
41
|
+
end
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
or you can return objects to the callbacks
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
class AClass
|
49
|
+
def self.a_complex_operation
|
50
|
+
complex stuff
|
51
|
+
yield ResponseCallback::Success.new(yield_var: awesome_object)
|
52
|
+
rescue => e
|
53
|
+
yield ResponseCallback::Fail.new(yield_var: error)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
AClass.a_complex_operation do |response|
|
58
|
+
response.on_success { |awesome_object| awesome_object.message }
|
59
|
+
response.on_fail { |error| deal_with_failure }
|
60
|
+
end
|
61
|
+
```
|
26
62
|
|
27
63
|
## Development
|
28
64
|
|
@@ -32,5 +68,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
68
|
|
33
69
|
## Contributing
|
34
70
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
71
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gabriel128/response_callback. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
72
|
+
|
73
|
+
## License
|
36
74
|
|
75
|
+
This project is licenced under the MIT license, see [LICENSE](LICENSE) for details.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: response_callback
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Torello
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|