evil_events 0.1.0rc9 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/CHANGELOG.md +4 -0
- data/README.md +2 -4
- data/evil_events.gemspec +2 -2
- data/lib/evil_events/core/broadcasting/emitter.rb +2 -2
- data/lib/evil_events/core/events/abstract_event.rb +2 -2
- data/lib/evil_events/core/events/event_factory.rb +65 -0
- data/lib/evil_events/core/events/manager/notifier.rb +19 -0
- data/lib/evil_events/core/events/serializers/base.rb +22 -0
- data/lib/evil_events/core/events/serializers/hash.rb +58 -37
- data/lib/evil_events/core/events/serializers/json.rb +41 -29
- data/lib/evil_events/core/events.rb +2 -1
- data/lib/evil_events/core/system/event_builder.rb +4 -4
- data/lib/evil_events/core/system/event_manager.rb +12 -2
- data/lib/evil_events/core/system/mock.rb +5 -1
- data/lib/evil_events/core/system.rb +1 -0
- data/lib/evil_events/version.rb +1 -1
- metadata +9 -8
- data/lib/evil_events/core/events/event_class_factory.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce935f449ea78c46b999cb78c539ebb0831ffe6c
|
4
|
+
data.tar.gz: d95c3b341243285c82c1955f2cf09f44d5d5cbe1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 722725a362de968307d9ff12b9b46f60b044110eafc404d77f1e9a96ff5e19c37d00853c2deb0a940021a8f6632ef17cdfba04791ba0c1ce4db3c95e7dfb1b10
|
7
|
+
data.tar.gz: 4bba1a00b98b3aa7f8ae62b5434698f8e71fa6ab6401ff167c73a5e8108a3fbd16beb06b698c54c26a4d82e7fafd62ebff2939cbe7c41fcc4b678d78fd947e38
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# EvilEvents
|
1
|
+
# EvilEvents · [![Gem Version](https://badge.fury.io/rb/evil_events.svg)](https://badge.fury.io/rb/evil_events) [![Build Status](https://travis-ci.org/0exp/evil_events.svg?branch=master)](https://travis-ci.org/0exp/evil_events) [![Coverage Status](https://coveralls.io/repos/github/0exp/evil_events/badge.svg?branch=master)](https://coveralls.io/github/0exp/evil_events?branch=master)
|
2
2
|
|
3
|
-
|
4
|
-
[![Build Status](https://travis-ci.org/ergosploit/evil_events.svg?branch=master)](https://travis-ci.org/ergosploit/evil_events)
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/github/ergosploit/evil_events/badge.svg?branch=master)](https://coveralls.io/github/ergosploit/evil_events?branch=master)
|
3
|
+
Coming soon... :smiling_imp:
|
data/evil_events.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.version = EvilEvents::VERSION
|
12
12
|
spec.authors = 'Rustam Ibragimov'
|
13
13
|
spec.email = 'iamdaiver@icloud.com'
|
14
|
-
spec.homepage = 'https://github.com/
|
14
|
+
spec.homepage = 'https://github.com/0exp/evil_events'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
spec.summary = 'Event subsystem for ruby applications'
|
17
17
|
spec.description = 'Ultra simple, but very flexible and fully customizable event subsystem ' \
|
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_development_dependency 'simplecov-json', '0.2'
|
40
40
|
spec.add_development_dependency 'rubocop', '0.51.0'
|
41
41
|
spec.add_development_dependency 'bundler', '1.15.4'
|
42
|
-
spec.add_development_dependency 'rake', '12.1
|
42
|
+
spec.add_development_dependency 'rake', '12.2.1'
|
43
43
|
spec.add_development_dependency 'rspec', '3.7.0'
|
44
44
|
spec.add_development_dependency 'rubocop-rspec', '1.19.0'
|
45
45
|
end
|
@@ -16,7 +16,7 @@ module EvilEvents::Core::Broadcasting
|
|
16
16
|
# @since 0.1.0
|
17
17
|
def emit(event)
|
18
18
|
raise IncorrectEventError unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
|
19
|
-
|
19
|
+
log_activity(event)
|
20
20
|
event.adapter.call(event)
|
21
21
|
end
|
22
22
|
|
@@ -40,7 +40,7 @@ module EvilEvents::Core::Broadcasting
|
|
40
40
|
# @return void
|
41
41
|
#
|
42
42
|
# @since 0.1.0
|
43
|
-
def
|
43
|
+
def log_activity(event)
|
44
44
|
activity = "EventEmitted(#{event.adapter_name})"
|
45
45
|
message = "ID: #{event.id} :: " \
|
46
46
|
"TYPE: #{event.type} :: " \
|
@@ -34,8 +34,8 @@ module EvilEvents::Core::Events
|
|
34
34
|
# @option metadata [Hash]
|
35
35
|
#
|
36
36
|
# @since 0.1.0
|
37
|
-
def initialize(payload: {}, metadata: {})
|
38
|
-
@id = EvilEvents::Shared::Crypto.uuid
|
37
|
+
def initialize(id: nil, payload: {}, metadata: {})
|
38
|
+
@id = id || EvilEvents::Shared::Crypto.uuid
|
39
39
|
@payload = build_payload(**payload)
|
40
40
|
@metadata = build_metadata(**metadata)
|
41
41
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EvilEvents::Core::Events
|
4
|
+
# @api private
|
5
|
+
# @since 0.1.1
|
6
|
+
module EventFactory
|
7
|
+
# @since 0.1.1
|
8
|
+
UNDEFINED_EVENT_ID = 'unknown'
|
9
|
+
|
10
|
+
module_function
|
11
|
+
|
12
|
+
# @param event_type [String]
|
13
|
+
# @raise [EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError]
|
14
|
+
# @return [Class{EvilEvents::Core::Events::AbstractEvent}]
|
15
|
+
#
|
16
|
+
# @since 0.1.1
|
17
|
+
def create_abstract_class(event_type)
|
18
|
+
Class.new(AbstractEvent).tap do |klass|
|
19
|
+
klass.type(event_type)
|
20
|
+
|
21
|
+
class << klass
|
22
|
+
def inherited(child_class)
|
23
|
+
child_class.type(type)
|
24
|
+
child_class.manage!
|
25
|
+
rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
|
26
|
+
EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(child_class)
|
27
|
+
raise
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# @param event_type [String]
|
34
|
+
# @param event_class_definitions [Proc]
|
35
|
+
# @yield [AbstractEvent]
|
36
|
+
# @raise [EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError]
|
37
|
+
# @return [Class{EvilEvents::Core::Events::AbstractEvent}]
|
38
|
+
#
|
39
|
+
# @since 0.1.1
|
40
|
+
def create_class(event_type, &event_class_definitions)
|
41
|
+
Class.new(AbstractEvent).tap do |klass|
|
42
|
+
begin
|
43
|
+
klass.type(event_type)
|
44
|
+
klass.manage!
|
45
|
+
klass.evaluate(&event_class_definitions) if block_given?
|
46
|
+
rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
|
47
|
+
EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(klass)
|
48
|
+
raise
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# @param event_class [Class{EvilEvents::Core::Events::AbstractEvent}]
|
54
|
+
# @option id [String, Object]
|
55
|
+
# @option payload [Hash]
|
56
|
+
# @option metadata [Hash]
|
57
|
+
# @return [EvilEvents::Core::Events::AbstractEvent]
|
58
|
+
#
|
59
|
+
# @api private
|
60
|
+
# @since 0.1.1
|
61
|
+
def restore_instance(event_class, id: UNDEFINED_EVENT_ID, payload: {}, metadata: {})
|
62
|
+
event_class.new(id: id || UNDEFINED_EVENT_ID, payload: payload, metadata: metadata)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -47,13 +47,32 @@ class EvilEvents::Core::Events::Manager
|
|
47
47
|
manager.subscribers.each do |subscriber|
|
48
48
|
begin
|
49
49
|
subscriber.notify(event)
|
50
|
+
log_activity(event, subscriber, :successful)
|
50
51
|
rescue StandardError => error
|
51
52
|
errors_stack << error
|
53
|
+
log_activity(event, subscriber, :failed)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
55
57
|
raise errors_stack unless errors_stack.empty?
|
56
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
# @param event [EvilEvents::Core::Events::AbstractEvent]
|
63
|
+
# @param subscriber [EvilEvents::Core::Events::Subscriber]
|
64
|
+
# @param status [String,Symbol]
|
65
|
+
# @return void
|
66
|
+
#
|
67
|
+
# @since 0.1.1
|
68
|
+
def log_activity(event, subscriber, status)
|
69
|
+
activity = "EventProcessed(#{event.type})"
|
70
|
+
message = "EVENT_ID: #{event.id} :: " \
|
71
|
+
"STATUS: #{status} :: " \
|
72
|
+
"SUBSCRIBER: #{subscriber.source_object}"
|
73
|
+
|
74
|
+
EvilEvents::Core::ActivityLogger.log(activity: activity, message: message)
|
75
|
+
end
|
57
76
|
end
|
58
77
|
end
|
59
78
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class EvilEvents::Core::Events::Serializers
|
4
|
+
# @api private
|
5
|
+
# @since 0.1.1
|
6
|
+
module Base
|
7
|
+
# @option type [String]
|
8
|
+
# @option id [String, Object]
|
9
|
+
# @option payload [Hash]
|
10
|
+
# @option metadata [Hash]
|
11
|
+
# @return [EvilEvents::Core::Events::AbstractEvent]
|
12
|
+
#
|
13
|
+
# @since 0.1.1
|
14
|
+
def restore_event_instance(type:, id:, payload:, metadata:)
|
15
|
+
event_class = EvilEvents::Core::Bootstrap[:event_system].resolve_event_class(type)
|
16
|
+
|
17
|
+
EvilEvents::Core::Events::EventFactory.restore_instance(
|
18
|
+
event_class, id: id, payload: payload, metadata: metadata
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -4,49 +4,70 @@ class EvilEvents::Core::Events::Serializers
|
|
4
4
|
# @api public
|
5
5
|
# @since 0.1.0
|
6
6
|
module Hash
|
7
|
-
|
7
|
+
# @since 0.1.1
|
8
|
+
extend Base
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
class << self
|
11
|
+
# @param event [EvilEvents::Core::Events::AbstractEvent]
|
12
|
+
# @raise [SerializationError]
|
13
|
+
# @return [::Hash]
|
14
|
+
#
|
15
|
+
# @since 0.1.0
|
16
|
+
def serialize(event)
|
17
|
+
raise SerializationError unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
{
|
20
|
+
id: event.id,
|
21
|
+
type: event.type,
|
22
|
+
payload: event.payload,
|
23
|
+
metadata: event.metadata
|
24
|
+
}
|
25
|
+
end
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
# rubocop:disable Metrics/AbcSize
|
28
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
29
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
30
|
+
|
31
|
+
# @param hash [::Hash]
|
32
|
+
# @raise [DeserializationError]
|
33
|
+
# @return [EvilEvents::Core::Events::AbstractEvent]
|
34
|
+
#
|
35
|
+
# @since 0.1.0
|
36
|
+
def deserialize(hash)
|
37
|
+
raise DeserializationError unless hash.is_a?(::Hash)
|
38
|
+
|
39
|
+
event_id = hash[:id] || hash['id']
|
40
|
+
event_type = hash[:type] || hash['type']
|
41
|
+
event_payload = hash[:payload] || hash['payload']
|
42
|
+
event_metadata = hash[:metadata] || hash['metadata']
|
43
|
+
|
44
|
+
raise DeserializationError unless event_type && event_payload && event_metadata
|
45
|
+
raise DeserializationError unless event_payload.is_a?(::Hash)
|
46
|
+
raise DeserializationError unless event_metadata.is_a?(::Hash)
|
47
|
+
|
48
|
+
restore_event_instance(
|
49
|
+
type: event_type,
|
50
|
+
id: event_id,
|
51
|
+
payload: symbolized_event_data(event_payload),
|
52
|
+
metadata: symbolized_event_data(event_metadata)
|
53
|
+
)
|
54
|
+
end
|
55
|
+
# rubocop:enable Metrics/AbcSize
|
56
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
57
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
58
|
+
|
59
|
+
private
|
39
60
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
61
|
+
# @param payload_hash [::Hash]
|
62
|
+
# @return [::Hash]
|
63
|
+
#
|
64
|
+
# @since 0.1.0
|
65
|
+
def symbolized_event_data(payload_hash)
|
66
|
+
payload_hash.each_pair.each_with_object({}) do |(key, value), result_hash|
|
67
|
+
result_hash[key.to_sym] = value
|
68
|
+
end
|
47
69
|
end
|
48
70
|
end
|
49
|
-
private_class_method :symbolized_event_data
|
50
71
|
end
|
51
72
|
|
52
73
|
# @since 0.1.0
|
@@ -4,40 +4,52 @@ class EvilEvents::Core::Events::Serializers
|
|
4
4
|
# @api public
|
5
5
|
# @since 0.1.0
|
6
6
|
module JSON
|
7
|
-
|
7
|
+
# @since 0.1.1
|
8
|
+
extend Base
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
class << self
|
11
|
+
# @param event [EvilEvents::Core::Events::AbstractEvent]
|
12
|
+
# @raise [SerializationError]
|
13
|
+
# @return [::Hash]
|
14
|
+
#
|
15
|
+
# @since 0.1.0
|
16
|
+
def serialize(event)
|
17
|
+
raise SerializationError unless event.is_a?(EvilEvents::Core::Events::AbstractEvent)
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
+
::JSON.generate(
|
20
|
+
id: event.id,
|
21
|
+
type: event.type,
|
22
|
+
payload: event.payload,
|
23
|
+
metadata: event.metadata
|
24
|
+
)
|
25
|
+
end
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
+
# @param json [String]
|
28
|
+
# @raise [DeserializationError]
|
29
|
+
# @return [EvilEvents::Core::Events::AbstractEvent]
|
30
|
+
#
|
31
|
+
# @since 0.1.0
|
32
|
+
def deserialize(json)
|
33
|
+
raise DeserializationError unless json.is_a?(String)
|
27
34
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
begin
|
36
|
+
json_hash = ::JSON.parse(json, symbolize_names: true)
|
37
|
+
event_id = json_hash[:id]
|
38
|
+
event_type = json_hash[:type]
|
39
|
+
event_payload = json_hash[:payload]
|
40
|
+
event_metadata = json_hash[:metadata]
|
41
|
+
raise DeserializationError unless event_type && event_payload && event_metadata
|
42
|
+
rescue ::JSON::ParserError
|
43
|
+
raise DeserializationError
|
44
|
+
end
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
|
46
|
+
restore_event_instance(
|
47
|
+
type: event_type,
|
48
|
+
id: event_id,
|
49
|
+
payload: event_payload,
|
50
|
+
metadata: event_metadata
|
51
|
+
)
|
52
|
+
end
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
@@ -5,6 +5,7 @@ module EvilEvents::Core
|
|
5
5
|
# @since 0.1.0
|
6
6
|
module Events
|
7
7
|
require_relative 'events/serializers'
|
8
|
+
require_relative 'events/serializers/base'
|
8
9
|
require_relative 'events/serializers/hash'
|
9
10
|
require_relative 'events/serializers/json'
|
10
11
|
require_relative 'events/event_extensions/type_aliasing'
|
@@ -25,6 +26,6 @@ module EvilEvents::Core
|
|
25
26
|
require_relative 'events/manager_registry'
|
26
27
|
require_relative 'events/subscriber'
|
27
28
|
require_relative 'events/subscriber/mixin'
|
28
|
-
require_relative 'events/
|
29
|
+
require_relative 'events/event_factory'
|
29
30
|
end
|
30
31
|
end
|
@@ -11,7 +11,7 @@ class EvilEvents::Core::System
|
|
11
11
|
#
|
12
12
|
# @since 0.1.0
|
13
13
|
def define_event_class(event_type, &event_class_definitions)
|
14
|
-
EvilEvents::Core::Events::
|
14
|
+
EvilEvents::Core::Events::EventFactory.create_class(event_type, &event_class_definitions)
|
15
15
|
end
|
16
16
|
|
17
17
|
# @param event_type [String]
|
@@ -19,7 +19,7 @@ class EvilEvents::Core::System
|
|
19
19
|
#
|
20
20
|
# @since 0.1.0
|
21
21
|
def define_abstract_event_class(event_type)
|
22
|
-
EvilEvents::Core::Events::
|
22
|
+
EvilEvents::Core::Events::EventFactory.create_abstract_class(event_type)
|
23
23
|
end
|
24
24
|
|
25
25
|
# @param serialized_event [String]
|
@@ -27,7 +27,7 @@ class EvilEvents::Core::System
|
|
27
27
|
#
|
28
28
|
# @since 0.1.0
|
29
29
|
def deserialize_from_json(serialized_event)
|
30
|
-
EvilEvents::Core::Events::Serializers
|
30
|
+
EvilEvents::Core::Events::Serializers[:json].deserialize(serialized_event)
|
31
31
|
end
|
32
32
|
|
33
33
|
# @param serialized_event [Hash]
|
@@ -35,7 +35,7 @@ class EvilEvents::Core::System
|
|
35
35
|
#
|
36
36
|
# @since 0.1.0
|
37
37
|
def deserialize_from_hash(serialized_event)
|
38
|
-
EvilEvents::Core::Events::Serializers
|
38
|
+
EvilEvents::Core::Events::Serializers[:hash].deserialize(serialized_event)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -81,8 +81,18 @@ class EvilEvents::Core::System
|
|
81
81
|
# @return [EvilEvents::Core::Events::AbstractEvent]
|
82
82
|
#
|
83
83
|
# @since 0.1.0
|
84
|
-
def resolve_event_object(event_type, payload: {}, metadata: {})
|
85
|
-
manager_of_event_type(event_type).event_class.new(
|
84
|
+
def resolve_event_object(event_type, id: nil, payload: {}, metadata: {})
|
85
|
+
manager_of_event_type(event_type).event_class.new(
|
86
|
+
id: id, payload: payload, metadata: metadata
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
# @param event_type [String]
|
91
|
+
# @return [Class{EvilEvents::Core::Events::AbstractEvent}]
|
92
|
+
#
|
93
|
+
# @since 0.1.0
|
94
|
+
def resolve_event_class(event_type)
|
95
|
+
manager_of_event_type(event_type).event_class
|
86
96
|
end
|
87
97
|
|
88
98
|
# @param event_class [EvilEvents::Core::Events::AbstractEvent]
|
@@ -61,7 +61,11 @@ class EvilEvents::Core::System
|
|
61
61
|
|
62
62
|
# @see EvilEvents::Core::System
|
63
63
|
# @since 0.1.0
|
64
|
-
def resolve_event_object(event_type, payload: {}, metadata: {}); end
|
64
|
+
def resolve_event_object(event_type, id: nil, payload: {}, metadata: {}); end
|
65
|
+
|
66
|
+
# @see EvilEvents::Core::System
|
67
|
+
# @since 0.1.0
|
68
|
+
def resolve_event_class(event_type); end
|
65
69
|
|
66
70
|
# @see EvilEvents::Core::System
|
67
71
|
# @since 0.1.0
|
data/lib/evil_events/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evil_events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Ibragimov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-monads
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - '='
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 12.1
|
187
|
+
version: 12.2.1
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - '='
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: 12.1
|
194
|
+
version: 12.2.1
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: rspec
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -258,7 +258,6 @@ files:
|
|
258
258
|
- lib/evil_events/core/config.rb
|
259
259
|
- lib/evil_events/core/events.rb
|
260
260
|
- lib/evil_events/core/events/abstract_event.rb
|
261
|
-
- lib/evil_events/core/events/event_class_factory.rb
|
262
261
|
- lib/evil_events/core/events/event_extensions/adapter_customizable.rb
|
263
262
|
- lib/evil_events/core/events/event_extensions/emittable.rb
|
264
263
|
- lib/evil_events/core/events/event_extensions/manageable.rb
|
@@ -269,12 +268,14 @@ files:
|
|
269
268
|
- lib/evil_events/core/events/event_extensions/payloadable/abstract_payload.rb
|
270
269
|
- lib/evil_events/core/events/event_extensions/serializable.rb
|
271
270
|
- lib/evil_events/core/events/event_extensions/type_aliasing.rb
|
271
|
+
- lib/evil_events/core/events/event_factory.rb
|
272
272
|
- lib/evil_events/core/events/manager.rb
|
273
273
|
- lib/evil_events/core/events/manager/notifier.rb
|
274
274
|
- lib/evil_events/core/events/manager/subscriber_list.rb
|
275
275
|
- lib/evil_events/core/events/manager_factory.rb
|
276
276
|
- lib/evil_events/core/events/manager_registry.rb
|
277
277
|
- lib/evil_events/core/events/serializers.rb
|
278
|
+
- lib/evil_events/core/events/serializers/base.rb
|
278
279
|
- lib/evil_events/core/events/serializers/hash.rb
|
279
280
|
- lib/evil_events/core/events/serializers/json.rb
|
280
281
|
- lib/evil_events/core/events/subscriber.rb
|
@@ -303,7 +304,7 @@ files:
|
|
303
304
|
- lib/evil_events/subscriber_mixin.rb
|
304
305
|
- lib/evil_events/types.rb
|
305
306
|
- lib/evil_events/version.rb
|
306
|
-
homepage: https://github.com/
|
307
|
+
homepage: https://github.com/0exp/evil_events
|
307
308
|
licenses:
|
308
309
|
- MIT
|
309
310
|
metadata: {}
|
@@ -318,9 +319,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
318
319
|
version: 2.2.7
|
319
320
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
320
321
|
requirements:
|
321
|
-
- - "
|
322
|
+
- - ">="
|
322
323
|
- !ruby/object:Gem::Version
|
323
|
-
version:
|
324
|
+
version: '0'
|
324
325
|
requirements: []
|
325
326
|
rubyforge_project:
|
326
327
|
rubygems_version: 2.6.14
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module EvilEvents::Core::Events
|
4
|
-
# @api private
|
5
|
-
# @since 0.1.0
|
6
|
-
module EventClassFactory
|
7
|
-
class << self
|
8
|
-
# @param event_type [String]
|
9
|
-
# @raise [EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError]
|
10
|
-
# @return [Class{EvilEvents::Core::Events::AbstractEvent}]
|
11
|
-
#
|
12
|
-
# @since 0.1.0
|
13
|
-
def create_abstract(event_type)
|
14
|
-
Class.new(AbstractEvent).tap do |klass|
|
15
|
-
klass.type(event_type)
|
16
|
-
|
17
|
-
class << klass
|
18
|
-
def inherited(child_class)
|
19
|
-
child_class.type(type)
|
20
|
-
child_class.manage!
|
21
|
-
rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
|
22
|
-
EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(child_class)
|
23
|
-
raise
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# @param event_type [String]
|
30
|
-
# @param event_class_definitions [Proc]
|
31
|
-
# @yield [AbstractEvent]
|
32
|
-
# @raise [EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError]
|
33
|
-
# @return [Class{EvilEvents::Core::Events::AbstractEvent}]
|
34
|
-
#
|
35
|
-
# @since 0.1.0
|
36
|
-
def create(event_type, &event_class_definitions)
|
37
|
-
Class.new(AbstractEvent).tap do |klass|
|
38
|
-
begin
|
39
|
-
klass.type(event_type)
|
40
|
-
klass.manage!
|
41
|
-
klass.evaluate(&event_class_definitions) if block_given?
|
42
|
-
rescue EvilEvents::Core::Events::ManagerRegistry::AlreadyManagedEventClassError
|
43
|
-
EvilEvents::Core::Bootstrap[:event_system].unregister_event_class(klass)
|
44
|
-
raise
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|