evt-consumer 0.3.0.0 → 0.4.0.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: e1d54c15b94cdb4d5f1bca14b2bef0d35a1d8e82
4
- data.tar.gz: 2e44a08b424289ba4225fdbdd6ff7c73e91e3842
3
+ metadata.gz: 134d9b7fe4b0476ee089ba6646012669a6d43a03
4
+ data.tar.gz: 6db97a91b342d36eb65b6a7927048ea37e194228
5
5
  SHA512:
6
- metadata.gz: 20ea5da08362f78ef225d55b8ccc9e7994db823b7d2914e3675812e8e68d8d6011628c83ff91177320bffae50a0044d2a820dde568b9ef1105f3c2f620e09827
7
- data.tar.gz: 8999009e287a384350d799f93f91cebb1e74d8a9279dbf86db34d1577fdbd6c134366a28b4ced2b3bab416d93f1ee3bebe1ffe84a1ba446a7a07d389b7bcd697
6
+ metadata.gz: 14b0bbed2bc44dc641cb303dc34dea202601e7f84020b13bba2d8b7a005a3efe6c7e8b4116ecc4166065f86a793724319664c66dd5a0d86f5efca6cd239d028b
7
+ data.tar.gz: 37f83db9333ca9eed131af329ade0da14cda1509370f61f48420f0f051560210fbd90baded6bf0462ad4822aa703b7881835d65a97abea99922ad4b22348c609
@@ -85,7 +85,9 @@ module Consumer
85
85
  cycle_timeout_milliseconds: cycle_timeout_milliseconds
86
86
  )
87
87
 
88
- Dispatch.configure self, handler_registry: self.class.handler_registry
88
+ handlers = self.class.handler_registry.get self
89
+
90
+ dispatch = Dispatch.configure self, handlers
89
91
 
90
92
  logger.debug { "Configuring (Batch Size: #{batch_size}, Session: #{session.inspect})" }
91
93
  end
@@ -11,6 +11,10 @@ module Consumer
11
11
  def handled_events
12
12
  @handled_events ||= []
13
13
  end
14
+
15
+ def handled?(event_data)
16
+ handled_events.include? event_data
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -4,23 +4,17 @@ module Consumer
4
4
 
5
5
  configure :dispatch
6
6
 
7
- attr_writer :handler_registry
7
+ initializer :handlers
8
8
 
9
- def handler_registry
10
- @handler_registry ||= HandlerRegistry.new
11
- end
9
+ def self.build(handlers=nil)
10
+ handlers = Array(handlers)
12
11
 
13
- def self.build(handler_registry: nil)
14
- instance = new
15
- instance.handler_registry = handler_registry unless handler_registry.nil?
16
- instance
12
+ new handlers
17
13
  end
18
14
 
19
15
  def call(event_data)
20
16
  logger.trace { "Dispatching event (#{LogText.event_data event_data})" }
21
17
 
22
- handlers = handler_registry.get
23
-
24
18
  handlers.each do |handle|
25
19
  handle.(event_data)
26
20
  end
@@ -13,21 +13,23 @@ module Consumer
13
13
  raise Error, error_message
14
14
  end
15
15
 
16
- if handler.respond_to? :build
17
- instance = handler.build
18
- else
19
- instance = handler
20
- end
21
-
22
- entries << instance
16
+ entries << handler
23
17
 
24
18
  logger.debug { "Handler registered (Handler: #{LogText.handler handler})" }
25
19
 
26
- instance
20
+ handler
27
21
  end
28
22
 
29
- def get
30
- entries.to_a
23
+ def get(consumer)
24
+ entries.map do |handler|
25
+ if handler.is_a? Proc
26
+ proc { |event_data|
27
+ consumer.instance_exec event_data, &handler
28
+ }
29
+ else
30
+ handler.build
31
+ end
32
+ end
31
33
  end
32
34
 
33
35
  def registered?(handler)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-consumer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.0
4
+ version: 0.4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project