messaging 3.5.1 → 3.5.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
  SHA256:
3
- metadata.gz: 441c7c47e5f82c297229ac9651d306554adc0571adf8533d7a98ac07d25223e3
4
- data.tar.gz: 892513550640905f8fe3db14921edc8ea18e4dc6b98c18d632e49bac1a9bdd94
3
+ metadata.gz: 061aaa840e0dbe849dec6ce3f8fb8d7747c4f2f507684bfc2999c0d1079ee1d3
4
+ data.tar.gz: 5ac1afb9efc65d3a7d73c4cbebb0f65379a01ea4bf69b9b0520bb4bd393a7d7b
5
5
  SHA512:
6
- metadata.gz: 029f9c439069df9db00b4adc8f948eeda489498bf9bf5acde6d85f2236b78636d627c7c99e045875cbdfd586da0fc1e68618d5aa378e3c8b2768ec654068434b
7
- data.tar.gz: 4c72b14e9646de2ad2a5898051cb1ee1b20ba3156aabc33d66cd67bede63cb42881308bd28614a199c1678b8c716053b0b68401badcd1a4870fb0811fb57b0c5
6
+ metadata.gz: 4c0f7ecae61ab6561785ef3d193a6e0f1337c1caab25d063205e4d8d5b84086737f6cf27a21f25a3dd20c12bb584abaad02558cfbd90f67cf63d9d2c5ea1f132
7
+ data.tar.gz: 4a18c65d9d8388685c5b39932e9829cb30427b0c3156a31992bbc6dd559b16a12e47e2e5998538e1b36cd194a20c31a52e0dd1cffd6130607ced188c64586082
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- messaging (3.5.1)
4
+ messaging (3.5.2)
5
5
  activerecord
6
6
  activesupport
7
7
  after_transaction
@@ -56,6 +56,17 @@ module Messaging
56
56
  routes.inline!(&block)
57
57
  end
58
58
 
59
+ def self.without_dispatch(&block)
60
+ current_dispatcher = Config.dispatcher.adapter
61
+ Config.dispatcher.adapter = :null_adapter
62
+
63
+ result = block.call
64
+
65
+ ensure
66
+ Config.dispatcher.adapter = current_dispatcher
67
+ result
68
+ end
69
+
59
70
  def self.category(name)
60
71
  message_store.category(name)
61
72
  end
@@ -30,6 +30,8 @@ module Messaging
30
30
  end
31
31
  end
32
32
 
33
+ Messaging::Adapters::Dispatcher.register(:null_adapter, memoize: true) { proc {} }
34
+
33
35
  require 'messaging/adapters/kafka'
34
36
  require 'messaging/adapters/postgres'
35
37
  require 'messaging/adapters/test'
@@ -5,6 +5,32 @@ require 'messaging/routing/enqueue_message_handler'
5
5
 
6
6
  module Messaging
7
7
  module Routing
8
+ def self.included(base)
9
+ base.send :extend, ClassMethods
10
+ end
11
+
12
+ module ClassMethods
13
+ def definitions
14
+ @definitions ||= []
15
+ end
16
+
17
+ def on(pattern, **options, &block)
18
+ definitions << { pattern: pattern, options: options, block: block }
19
+ end
20
+
21
+ def new(*args, &block)
22
+ instance = allocate
23
+
24
+ # Pre-initialize
25
+ definitions.each do |definition|
26
+ instance.on(definition[:pattern], definition[:options], &definition[:block])
27
+ end
28
+
29
+ instance.send(:initialize, *args, &block)
30
+ instance
31
+ end
32
+ end
33
+
8
34
  # Public: Sets up routes for the events that matches the given pattern
9
35
  #
10
36
  # pattern - Which messages to route. Can be a string, a regexp,
@@ -44,8 +70,8 @@ module Messaging
44
70
  end
45
71
 
46
72
  # Internal: Handles the message with the matching subscribers
47
- def handle(message)
48
- routes.map { |route| route.call(message) }
73
+ def handle(message, context = self)
74
+ routes.map { |route| route.call(message, context) }
49
75
  message
50
76
  end
51
77
 
@@ -15,10 +15,10 @@ module Messaging
15
15
  verify_handler!
16
16
  end
17
17
 
18
- def call(message)
18
+ def call(message, context = self)
19
19
  return unless @matcher.matches?(message)
20
20
 
21
- @handler.call(message)
21
+ context.instance_exec(message, &@handler)
22
22
  end
23
23
 
24
24
  def topics
@@ -1,3 +1,3 @@
1
1
  module Messaging
2
- VERSION = '3.5.1'.freeze
2
+ VERSION = '3.5.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bukowskis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-13 00:00:00.000000000 Z
11
+ date: 2020-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord