notification_center 0.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- notification_center (0.2)
4
+ notification_center (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -23,9 +23,8 @@ module NotificationCenter
23
23
  def _notify! event, *args
24
24
  event_handler = "#{event}_#{method_suffix}"
25
25
  receivers = @@events[event]
26
- for receiver in receivers
27
- receiver.send event_handler, *args
28
- end
26
+ result = receivers.map{|receiver| receiver.send(event_handler, *args)}
27
+ return (result.size == 1 ? result[0] : result)
29
28
  end
30
29
 
31
30
  def _with_cache event
@@ -1,3 +1,3 @@
1
1
  module NotificationCener
2
- VERSION = "0.3".freeze
2
+ VERSION = "0.3.1".freeze
3
3
  end
@@ -1,6 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
-
4
3
  describe NotificationCenter do
5
4
  describe '.post_notification' do
6
5
  before { NotificationCenter::Cache.flush_cache! }
@@ -15,6 +14,12 @@ describe NotificationCenter do
15
14
  NotificationCenter.post_notification :imaginary_event
16
15
  end
17
16
 
17
+ it "should return listener result" do
18
+ EventListener = Class.new { observe :event }
19
+ EventListener.should_receive(:event_handler).and_return(:result)
20
+ NotificationCenter.post_notification(:event).should eql(:result)
21
+ end
22
+
18
23
  context 'when cache disabled' do
19
24
  before { NotificationCenter.enable_cache = false }
20
25
  it "should not fire event twice" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notification_center
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-11 00:00:00.000000000 Z
12
+ date: 2012-07-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler