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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9633a2d2494f3275f605be0b883e85d37e74d4ef
4
- data.tar.gz: 54abda822f7917adbd7c9223b73dc54bd002597e
3
+ metadata.gz: 66a0ee4f7bad4eeec48612c958b13f298a25294c
4
+ data.tar.gz: 577ec76966a26009c858ec0144f7b11114dea71d
5
5
  SHA512:
6
- metadata.gz: 1e68fc86c720bec01d42aa4970391f51f0c070757503b4a66c064b1d9bc9cfff2fc1b9c2093cc42cf15f2b6fdf44cf52ba481ccb3546d88d4b450aba7faf6cfa
7
- data.tar.gz: 17142e23a6d3b8f7ba5cec6c4a4ba154aa506eca2b52c708fa623ac04ca514a7ab44bd25d3a07b3c910c34b70cb0f9702e1262ed0ffff236f17551fc34245ad6
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
@@ -14,7 +14,10 @@ module Yeller
14
14
  end
15
15
  end
16
16
 
17
- def subscribe( subscriber_class, method, *keys )
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 )
@@ -4,8 +4,8 @@ module Yeller
4
4
 
5
5
  included do
6
6
  class << self
7
- def subscribe( method, *keys )
8
- Yeller.subscribe( self, method, *keys)
7
+ def subscribe( options )
8
+ Yeller.subscribe( self, options )
9
9
  end
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module Yeller
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg