koine-event_manager 1.0.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -0
- data/lib/koine/event_manager/event_manager.rb +4 -0
- data/lib/koine/event_manager/event_manager_aware.rb +13 -0
- data/lib/koine/event_manager/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 775de95f0d2768e1147c12eea5a66dd28fd23fee
|
4
|
+
data.tar.gz: 6bb2f1ef07c98614d119a615769f67e318f32e77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c6b9922bd907cd760a065bb74a564142b6817881a213e52b0674535beb223b954eda7e418e389c101b71a29ffbde0ab7d3b98329318453a59d2e57e9d5896dc
|
7
|
+
data.tar.gz: 7c653751ff81a31f53ec7267aa952225b61de01f50b9e1181a3b506cdd18e22270c3131e043ae25383e7c3a3a95b32bfacee96c317b1c077930711bd793b7ccd
|
data/README.md
CHANGED
@@ -83,6 +83,38 @@ And trigger the event on the event manager
|
|
83
83
|
event_manager.trigger(UserSignedIn.new(some_user))
|
84
84
|
```
|
85
85
|
|
86
|
+
## Adding event manager awareness to your classes
|
87
|
+
|
88
|
+
**CAUTION**: This make use of the singleton instance of event manager.
|
89
|
+
Singletons are usually a bad idea, so prefer dependency injection over
|
90
|
+
singleton instances.
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
require "koine/event_manager/event_manager_aware"
|
94
|
+
|
95
|
+
class MyModel
|
96
|
+
include Koine::EventManager::EventManagerAware
|
97
|
+
|
98
|
+
def some_method
|
99
|
+
event_manager.trigger(SomeEvent.new(foo: :bar))
|
100
|
+
end
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
The above is the same as:
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
class MyModel
|
108
|
+
def some_method
|
109
|
+
event_manager.trigger(SomeEvent.new(foo: :bar))
|
110
|
+
end
|
111
|
+
|
112
|
+
def event_manager
|
113
|
+
Koine::EventManager::EventManager.instance
|
114
|
+
end
|
115
|
+
end
|
116
|
+
```
|
117
|
+
|
86
118
|
## Development
|
87
119
|
|
88
120
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koine-event_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Jacobus
|
@@ -115,6 +115,7 @@ files:
|
|
115
115
|
- lib/koine/event_manager.rb
|
116
116
|
- lib/koine/event_manager/event_listener.rb
|
117
117
|
- lib/koine/event_manager/event_manager.rb
|
118
|
+
- lib/koine/event_manager/event_manager_aware.rb
|
118
119
|
- lib/koine/event_manager/version.rb
|
119
120
|
homepage: https://github.com/mjacobus/koine-event-manager
|
120
121
|
licenses:
|