reactor 0.6.1 → 0.6.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0abc4277ddd966a53c908760c99f67e32c4753e9
|
4
|
+
data.tar.gz: a5990f202fda7c2987d66c68d738bc126f568f75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d8af444ef13fc7e8e142b3392d04a841a340ef84ef5a2155a882fbedf30f1d2b94b90f90b76579b33ec7390fb9ee3bffc0aeccdc00ab0db8fd12aa8173feb07
|
7
|
+
data.tar.gz: 788bb1bda4586fbcdd2d6c6f19da8de2cc5d17f161b33517beb7459f7f9b2e9b26f7a5557acdf3017ce3a1d377f4ccd2e7c1fa7322ae2300d8fcfa25b089cbf8
|
@@ -13,10 +13,14 @@ module Reactor::Subscribable
|
|
13
13
|
|
14
14
|
def self.create(event, method = nil, options = {}, &block)
|
15
15
|
handler_class_prefix = event == '*' ? 'Wildcard': event.to_s.camelize
|
16
|
-
|
16
|
+
i = 0
|
17
|
+
begin
|
18
|
+
new_class = "#{handler_class_prefix}Handler#{i}"
|
19
|
+
i+= 1
|
20
|
+
end while Reactor::StaticSubscribers.const_defined?(new_class)
|
17
21
|
|
18
22
|
eval %Q{
|
19
|
-
class
|
23
|
+
class Reactor::StaticSubscribers::#{new_class}
|
20
24
|
include Sidekiq::Worker
|
21
25
|
|
22
26
|
cattr_accessor :method, :delay, :source, :in_memory
|
@@ -40,7 +44,7 @@ module Reactor::Subscribable
|
|
40
44
|
end
|
41
45
|
}
|
42
46
|
|
43
|
-
new_class = new_class.constantize
|
47
|
+
new_class = "Reactor::StaticSubscribers::#{new_class}".constantize
|
44
48
|
new_class.method = method || block
|
45
49
|
new_class.delay = options[:delay] || 0
|
46
50
|
new_class.source = options[:source]
|
data/lib/reactor/version.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
3
|
class Auction < ActiveRecord::Base
|
5
4
|
on_event :bid_made do |event|
|
6
5
|
event.target.update_column :status, 'first_bid_made'
|
7
6
|
end
|
8
7
|
|
9
8
|
on_event :puppy_delivered, :ring_bell
|
9
|
+
on_event :puppy_delivered, -> (event) { }
|
10
10
|
on_event :any_event, -> (event) { puppies! }
|
11
11
|
on_event :pooped, :pick_up_poop, delay: 5.minutes
|
12
12
|
on_event '*' do |event|
|
@@ -31,6 +31,13 @@ describe Reactor::Subscribable do
|
|
31
31
|
Reactor::Event.publish(:bid_made, target: Auction.create)
|
32
32
|
end
|
33
33
|
|
34
|
+
describe 'building uniquely named subscriber handler classes' do
|
35
|
+
it 'adds a static subscriber to the global lookup constant' do
|
36
|
+
expect(Reactor::SUBSCRIBERS['puppy_delivered'][0]).to eq(Reactor::StaticSubscribers::PuppyDeliveredHandler0)
|
37
|
+
expect(Reactor::SUBSCRIBERS['puppy_delivered'][1]).to eq(Reactor::StaticSubscribers::PuppyDeliveredHandler1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
34
41
|
describe 'binding symbol of class method' do
|
35
42
|
it 'fires on event' do
|
36
43
|
Auction.should_receive(:ring_bell)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reactor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winfred
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-
|
15
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: sidekiq
|