realm-core 0.7.0 → 0.7.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7384c47348b48ded26a37ce232e0ccb357a8a6e7e1f25667d614f9dc37a8af2
|
4
|
+
data.tar.gz: 0b4ae6a517da7377f458111447453423652b35166fadbb60df74337727d68068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aa7ec7d85ce6777b58d13f6bf3ff691e83901124951f7ebb38b60c2fbf929bf58b6daec23631f8308147be8614f7ed82edce045855620de9ba6b05abab424b0
|
7
|
+
data.tar.gz: ca2605753e57f0290a2b834f455389dfcc57a0ad51515b7fdc0b75c4daf2a166d32c9039aea45ce09a9995d3807beb0ac8ae97b38c2b9682658e6d28f0237cb1
|
data/lib/realm/error.rb
CHANGED
data/lib/realm/event_factory.rb
CHANGED
@@ -7,6 +7,7 @@ module Realm
|
|
7
7
|
class EventFactory
|
8
8
|
def initialize(events_module)
|
9
9
|
@events_module = events_module
|
10
|
+
@event_class_map = collect_event_classes(events_module)
|
10
11
|
end
|
11
12
|
|
12
13
|
def create_event(event_type, correlate: nil, cause: nil, **attributes)
|
@@ -19,15 +20,25 @@ module Realm
|
|
19
20
|
def event_class_for(event_type)
|
20
21
|
return event_type if event_type.respond_to?(:new)
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
raise EventClassMissing.new(event_type, @events_module)
|
23
|
+
@event_class_map.fetch(event_type.to_s) do
|
24
|
+
raise EventClassMissing.new(event_type, @events_module)
|
25
|
+
end
|
27
26
|
end
|
28
27
|
|
29
28
|
private
|
30
29
|
|
30
|
+
def collect_event_classes(root_module)
|
31
|
+
root_module_str = root_module.to_s
|
32
|
+
root_module.constants.each_with_object({}) do |const_sym, all|
|
33
|
+
const = root_module.const_get(const_sym)
|
34
|
+
if !(const < Event) && const.to_s.start_with?(root_module_str)
|
35
|
+
all.merge!(collect_event_classes(const))
|
36
|
+
elsif const < Event
|
37
|
+
all[const.type] = const
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
31
42
|
def enhance_head(head, correlate:, cause:)
|
32
43
|
head[:correlation_id] = correlate.head.correlation_id if correlate
|
33
44
|
if cause.is_a?(Event)
|
data/lib/realm/event_handler.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_support/core_ext/string'
|
4
|
-
require 'realm/
|
4
|
+
require 'realm/persistence'
|
5
5
|
require 'realm/mixins/context_injection'
|
6
6
|
require 'realm/mixins/reactive'
|
7
7
|
require 'realm/mixins/repository_helper'
|
@@ -40,7 +40,7 @@ module Realm
|
|
40
40
|
|
41
41
|
def identifier(value = :undefined)
|
42
42
|
if value == :undefined
|
43
|
-
defined?(@identifier) ? @identifier : name.gsub(/(Domain|
|
43
|
+
defined?(@identifier) ? @identifier : name.gsub(/(Domain|(Event)?Handlers?)/, '').underscore.gsub(%r{/+}, '-')
|
44
44
|
else
|
45
45
|
@identifier = value
|
46
46
|
end
|
@@ -84,7 +84,7 @@ module Realm
|
|
84
84
|
def call(event)
|
85
85
|
event_to_methods(event).each do |method_name|
|
86
86
|
send(method_name, event)
|
87
|
-
rescue Realm::
|
87
|
+
rescue Realm::Persistence::Conflict => e
|
88
88
|
context[:logger]&.warn(e.full_message)
|
89
89
|
end
|
90
90
|
end
|
data/lib/realm/event_router.rb
CHANGED
@@ -31,7 +31,7 @@ module Realm
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def trigger(identifier, attributes = {})
|
34
|
-
namespace, event_type = identifier.to_s.include?('
|
34
|
+
namespace, event_type = identifier.to_s.include?('/') ? identifier.split('/') : [nil, identifier]
|
35
35
|
gateway_for(namespace).trigger(event_type, attributes)
|
36
36
|
end
|
37
37
|
|
@@ -17,7 +17,7 @@ module Realm
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def add_listener(event_type, listener)
|
20
|
-
(@listener_map[event_type] ||= []) << listener
|
20
|
+
(@listener_map[event_type.to_sym] ||= []) << listener
|
21
21
|
end
|
22
22
|
|
23
23
|
def trigger(event_type, attributes = {})
|
@@ -39,7 +39,7 @@ module Realm
|
|
39
39
|
private
|
40
40
|
|
41
41
|
def find_listeners(event_type)
|
42
|
-
@listener_map.fetch_values(event_type, :any) { [] }.flatten
|
42
|
+
@listener_map.fetch_values(event_type.to_sym, :any) { [] }.flatten
|
43
43
|
end
|
44
44
|
|
45
45
|
def gateways
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realm-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- developers@reevoo.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|