reactor 0.11.2 → 0.11.4

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: 8252972581cc95bb4ac6cd93d5a99cc760c67b70
4
- data.tar.gz: 8b95946e4f717c78d16ce36e5da4162cb3776fbe
3
+ metadata.gz: 6f2967da3845ee85524fe9c738839f0e6fdb29c7
4
+ data.tar.gz: c0ed7956ea7c152528db44ec1c898c47415d1cb5
5
5
  SHA512:
6
- metadata.gz: 9e09bf4d0cb61913a73877f9b71066c9bc2571ae8d762acb9bd4fda882395f11ec796af4d938e46406aa745bafec05b00a8e49c283bc63ef0bf51b9afce3d29b
7
- data.tar.gz: 1f2399204102e398cd463c761d382d9b4633d6bfcc8f4e82dbfcd7b9326f9527cd6a8504484775daae05d0d1dccd53e82d47fa89690c86111cfe1c22dba0b140
6
+ metadata.gz: a155ca4b6daf0250992a8e3a9a15f8b5a56ccab20a5e8c04ee80e26e19b234a4a9e486e5f6932bbb76226a7d3d3570235402a9eb9873175b0f4c398dc6788be7
7
+ data.tar.gz: 106ba452f9d9a2b2623157738f271f20afee7a6df280e4f9971a071ff572361e60fae79e414329076a0d4233bce55b8a9e9f2c77b21057f916be4f473ed9ab60
data/Changes.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Reactor Change Log
2
2
 
3
+ 0.11.4
4
+ -----------
5
+ Fixes an issue related to class reloading in Rails development and test modes
6
+
3
7
  0.11.2
4
8
  -----------
5
9
  Safely handle bad UTF-8 encoded strings passed in as event arguments
data/Gemfile.lock CHANGED
@@ -45,7 +45,7 @@ GEM
45
45
  rspec-core (~> 3.4.0)
46
46
  rspec-expectations (~> 3.4.0)
47
47
  rspec-mocks (~> 3.4.0)
48
- rspec-core (3.4.2)
48
+ rspec-core (3.4.4)
49
49
  rspec-support (~> 3.4.0)
50
50
  rspec-expectations (3.4.0)
51
51
  diff-lcs (>= 1.2.0, < 2.0)
@@ -4,18 +4,25 @@ module Reactor::Subscribable
4
4
  class EventHandlerAlreadyDefined < StandardError ; end
5
5
 
6
6
  module ClassMethods
7
+
7
8
  def on_event(*args, &block)
8
9
  options = args.extract_options!
9
10
  event, method = args
10
- (Reactor::SUBSCRIBERS[event.to_s] ||= []).push(create_static_subscriber(event, method, options, &block))
11
+ if subscriber = create_static_subscriber(event, method, options, &block)
12
+ (Reactor::SUBSCRIBERS[event.to_s] ||= []).push(subscriber)
13
+ end
11
14
  end
12
15
 
13
16
  private
14
17
 
15
18
  def create_static_subscriber(event, method = nil, options = {}, &block)
16
19
  worker_class = build_worker_class
20
+ handler_name = handler_name(event, options[:handler_name])
21
+ check_for_duplicate_handler_name(handler_name)
17
22
 
18
- name_worker_class worker_class, handler_name(event, options[:handler_name])
23
+ # return if the handler has already been defined (in the case of the class being reloaded)
24
+ return if static_subscriber_namespace.const_defined?(handler_name)
25
+ name_worker_class worker_class, handler_name
19
26
 
20
27
  worker_class.tap do |k|
21
28
  k.source = self
@@ -31,6 +38,10 @@ module Reactor::Subscribable
31
38
  "#{event == '*' ? 'Wildcard': event.to_s.camelize}Handler"
32
39
  end
33
40
 
41
+ def event_handler_names
42
+ @event_handler_names ||= []
43
+ end
44
+
34
45
  def build_worker_class
35
46
  Class.new do
36
47
  include Sidekiq::Worker
@@ -57,13 +68,17 @@ module Reactor::Subscribable
57
68
  end
58
69
  end
59
70
 
60
- def name_worker_class(klass, handler_name)
61
- if static_subscriber_namespace.const_defined?(handler_name)
71
+ def check_for_duplicate_handler_name(handler_name)
72
+ if event_handler_names.include?(handler_name)
62
73
  raise EventHandlerAlreadyDefined.new(
63
74
  "A Reactor event named #{handler_name} already has been defined on #{static_subscriber_namespace}.
64
75
  Specify a `:handler_name` option on your subscriber's `on_event` declaration to name this event handler deterministically."
65
76
  )
66
77
  end
78
+ event_handler_names << handler_name
79
+ end
80
+
81
+ def name_worker_class(klass, handler_name)
67
82
  static_subscriber_namespace.const_set(handler_name, klass)
68
83
  end
69
84
 
@@ -1,3 +1,3 @@
1
1
  module Reactor
2
- VERSION = "0.11.2"
2
+ VERSION = "0.11.4"
3
3
  end
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.11.2
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - winfred
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-03-18 00:00:00.000000000 Z
14
+ date: 2016-03-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: sidekiq