yeller 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -2
- data/lib/yeller/broadcaster.rb +4 -1
- data/lib/yeller/subscribable.rb +2 -2
- data/lib/yeller/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66a0ee4f7bad4eeec48612c958b13f298a25294c
|
4
|
+
data.tar.gz: 577ec76966a26009c858ec0144f7b11114dea71d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4936e8e8c42c534ba7137250ed76e8ca2d12df3adc0dee2665a33004145e000bbc5651a48fb90d4862fd080f82bb5d4e5ffb382002fb49aad307fc0650a9e858
|
7
|
+
data.tar.gz: b4c3cf53fe0ade1a2333eabb1484261a31a1bece2323d4736976ed5c1de7481c409b61f02e316d853809e441442a8e672828123a1e277ebfe3bdb2ada7017c12
|
data/README.md
CHANGED
@@ -49,7 +49,10 @@ class MyListenerClass
|
|
49
49
|
include Yeller::Subscribable
|
50
50
|
|
51
51
|
# the subscribable module provides this method
|
52
|
-
subscribe :react, "keys", "my"
|
52
|
+
subscribe with: :react, to: ["keys", "my"]
|
53
|
+
|
54
|
+
# or, if you have just the one key
|
55
|
+
subscribe with: :react, to: "key"
|
53
56
|
|
54
57
|
def self.react( message )
|
55
58
|
puts "received #{message}"
|
@@ -62,7 +65,7 @@ which will print "received HELLO, EVERYONE!" when `MyLoudClass.yell!` is called.
|
|
62
65
|
You can also subscribe on the insance level with
|
63
66
|
|
64
67
|
```ruby
|
65
|
-
Yeller.subscribe( MyListenerClass.new, :instance_level_react, "key", "other key" )
|
68
|
+
Yeller.subscribe( MyListenerClass.new, with: :instance_level_react, to: ["key", "other key"] )
|
66
69
|
```
|
67
70
|
|
68
71
|
## Development
|
data/lib/yeller/broadcaster.rb
CHANGED
@@ -14,7 +14,10 @@ module Yeller
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def subscribe( subscriber_class,
|
17
|
+
def subscribe( subscriber_class, options )
|
18
|
+
keys = Array(options[:to])
|
19
|
+
method = options[:with]
|
20
|
+
raise KeyError, "expected :with and :to to be present in subscriber definition" unless method && keys
|
18
21
|
keys.each do |key|
|
19
22
|
normalized_key = Key.normalize(key)
|
20
23
|
subscriber = Subscriber.new( subscriber_class, method, normalized_key )
|
data/lib/yeller/subscribable.rb
CHANGED
data/lib/yeller/version.rb
CHANGED