object_pub_sub 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/object_pub_sub.rb +4 -4
- data/lib/object_pub_sub/version.rb +1 -1
- data/spec/object_pub_sub_spec.rb +7 -0
- metadata +4 -4
data/lib/object_pub_sub.rb
CHANGED
@@ -29,9 +29,9 @@ module ObjectPubSub
|
|
29
29
|
@subscribers << callback_pair
|
30
30
|
end
|
31
31
|
|
32
|
-
def publish_event(data
|
32
|
+
def publish_event(*data)
|
33
33
|
@subscribers.each do |subscriber, callback_method|
|
34
|
-
subscriber.send(callback_method, data)
|
34
|
+
subscriber.send(callback_method, *data)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -46,8 +46,8 @@ module ObjectPubSub
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
def publish_event(event_name, data
|
50
|
-
subscriber_list_for(event_name).publish_event(data)
|
49
|
+
def publish_event(event_name, *data)
|
50
|
+
subscriber_list_for(event_name).publish_event(*data)
|
51
51
|
end
|
52
52
|
|
53
53
|
private
|
data/spec/object_pub_sub_spec.rb
CHANGED
@@ -77,6 +77,13 @@ describe ObjectPubSub do
|
|
77
77
|
subject.publish_event(:event_a, :some_data)
|
78
78
|
end
|
79
79
|
|
80
|
+
it "can publish multiple data arguments along with an event" do
|
81
|
+
subject.add_subscriber(subscriber, :event_a)
|
82
|
+
|
83
|
+
subscriber.should_receive(:event_a).with(:some_data, :some_more_data)
|
84
|
+
subject.publish_event(:event_a, :some_data, :some_more_data)
|
85
|
+
end
|
86
|
+
|
80
87
|
it "allows the subscriber to specify a custom callback method for some events" do
|
81
88
|
subject.add_subscriber(subscriber, :event_b, :event_a => :handle_event_a)
|
82
89
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: object_pub_sub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
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-12-
|
12
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
73
|
version: '0'
|
74
74
|
segments:
|
75
75
|
- 0
|
76
|
-
hash:
|
76
|
+
hash: 1243387231083684341
|
77
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
78
|
none: false
|
79
79
|
requirements:
|
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
version: '0'
|
83
83
|
segments:
|
84
84
|
- 0
|
85
|
-
hash:
|
85
|
+
hash: 1243387231083684341
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
88
|
rubygems_version: 1.8.23
|