evnt 3.6.2 → 3.6.3
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: d6914876f490b7f506f0bd135ac831e8acffb9e5fb43415f58058caabd247b89
|
4
|
+
data.tar.gz: bccddfbc82d68e6b0a4799dd1db223cb8eb29c53b74b2ce59cfbcbd208d15ad5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c66d8707ed27a203347788861f27f7acdb6220bae5fe6288ce63b4b162dafc19ace35fe0e4e077274e743f908f1c0ca2acd379cdc02441cf1aeb2956ba502ddf
|
7
|
+
data.tar.gz: 7e01984cd1ae84b961ff41fad33e0fd518c5543c172eb821a5315936767637615e81efb3d215e408fa824e79c087d11e4daeceba8d76c8f57f17c97fc76aff08
|
data/README.md
CHANGED
data/lib/evnt/command.rb
CHANGED
@@ -213,11 +213,10 @@ module Evnt
|
|
213
213
|
|
214
214
|
# This function sets the single validation request for a command parameter.
|
215
215
|
def validates(param, options)
|
216
|
-
|
217
|
-
|
218
|
-
command_validations = @validations
|
216
|
+
@@validations ||= []
|
217
|
+
@@validations.push(param: param, options: options)
|
219
218
|
|
220
|
-
define_method('_validations', -> {
|
219
|
+
define_method('_validations', -> { @@validations })
|
221
220
|
end
|
222
221
|
|
223
222
|
# This function sets the normalize params function for the command.
|
data/lib/evnt/event.rb
CHANGED
@@ -16,7 +16,17 @@ module Evnt
|
|
16
16
|
attr_reader :name
|
17
17
|
|
18
18
|
##
|
19
|
-
# Attribute containings the list of attributes of the event.
|
19
|
+
# Attribute containings the list of payload attributes of the event.
|
20
|
+
##
|
21
|
+
attr_reader :payload_attributes
|
22
|
+
|
23
|
+
##
|
24
|
+
# Attribute containings the list of extras attributes of the event.
|
25
|
+
##
|
26
|
+
attr_reader :extras_attributes
|
27
|
+
|
28
|
+
##
|
29
|
+
# DEPRECATED: Attribute containings the list of attributes of the event.
|
20
30
|
##
|
21
31
|
attr_reader :attributes
|
22
32
|
|
@@ -49,6 +59,7 @@ module Evnt
|
|
49
59
|
def initialize(params = {})
|
50
60
|
_init_event_data(params)
|
51
61
|
_validate_payload
|
62
|
+
_validate_extras
|
52
63
|
_run_event_steps
|
53
64
|
_notify_handlers if @state[:saved]
|
54
65
|
end
|
@@ -111,7 +122,9 @@ module Evnt
|
|
111
122
|
|
112
123
|
# set name and attributes
|
113
124
|
@name = _safe_name
|
114
|
-
@
|
125
|
+
@payload_attributes = _safe_payload_attributes
|
126
|
+
@extras_attributes = _safe_extras_attributes
|
127
|
+
@attributes = _safe_payload_attributes # DEPRECATED
|
115
128
|
|
116
129
|
# set payload
|
117
130
|
payload = params.reject { |k, _v| k[0] == '_' }
|
@@ -137,10 +150,17 @@ module Evnt
|
|
137
150
|
# This function validates all payload and check they are completed.
|
138
151
|
def _validate_payload
|
139
152
|
# check all attributes are present
|
140
|
-
check_attr = (@payload.keys - [:evnt]) == @
|
153
|
+
check_attr = (@payload.keys - [:evnt]).sort == @payload_attributes.sort
|
141
154
|
raise 'Event parameters are not correct' unless check_attr
|
142
155
|
end
|
143
156
|
|
157
|
+
# This function validates all extras and check they are completed.
|
158
|
+
def _validate_extras
|
159
|
+
# check all attributes are present
|
160
|
+
check_attr = @extras.keys.sort == @extras_attributes.sort
|
161
|
+
puts 'Event extras are not correct; in future releases they will be required' unless check_attr
|
162
|
+
end
|
163
|
+
|
144
164
|
# This function calls requested steps for the event.
|
145
165
|
def _run_event_steps
|
146
166
|
_safe_write_event
|
@@ -169,8 +189,13 @@ module Evnt
|
|
169
189
|
''
|
170
190
|
end
|
171
191
|
|
172
|
-
def
|
173
|
-
return
|
192
|
+
def _safe_payload_attributes
|
193
|
+
return _payload_attributes if defined?(_payload_attributes)
|
194
|
+
[]
|
195
|
+
end
|
196
|
+
|
197
|
+
def _safe_extras_attributes
|
198
|
+
return _extras_attributes if defined?(_extras_attributes)
|
174
199
|
[]
|
175
200
|
end
|
176
201
|
|
@@ -192,11 +217,10 @@ module Evnt
|
|
192
217
|
|
193
218
|
# This function sets the default options that should be used by the event.
|
194
219
|
def default_options(options)
|
195
|
-
|
196
|
-
|
197
|
-
event_options = @options
|
220
|
+
@@options ||= {}
|
221
|
+
@@options.merge!(options)
|
198
222
|
|
199
|
-
define_method('_default_options', -> {
|
223
|
+
define_method('_default_options', -> { @@options })
|
200
224
|
end
|
201
225
|
|
202
226
|
# This function sets the name for the event.
|
@@ -204,22 +228,36 @@ module Evnt
|
|
204
228
|
define_method('_name', -> { return name })
|
205
229
|
end
|
206
230
|
|
207
|
-
# This function sets the list of attributes for the event.
|
231
|
+
# This function sets the list of payload attributes for the event.
|
232
|
+
def payload_attributes_are(*attributes)
|
233
|
+
@@payload_attributes ||= []
|
234
|
+
@@payload_attributes.concat(attributes).uniq!
|
235
|
+
|
236
|
+
define_method('_payload_attributes', -> { @@payload_attributes })
|
237
|
+
end
|
238
|
+
|
239
|
+
# This function sets the list of extras attributes for the event.
|
240
|
+
def extras_attributes_are(*attributes)
|
241
|
+
@@extras_attributes ||= []
|
242
|
+
@@extras_attributes.concat(attributes).uniq!
|
243
|
+
|
244
|
+
define_method('_extras_attributes', -> { @@extras_attributes })
|
245
|
+
end
|
246
|
+
|
247
|
+
# DEPRECATED: This function sets the list of attributes for the event.
|
208
248
|
def attributes_are(*attributes)
|
209
|
-
|
210
|
-
|
211
|
-
event_attributes = @attributes
|
249
|
+
@@payload_attributes ||= []
|
250
|
+
@@payload_attributes.concat(attributes).uniq!
|
212
251
|
|
213
|
-
define_method('
|
252
|
+
define_method('_payload_attributes', -> { @@payload_attributes })
|
214
253
|
end
|
215
254
|
|
216
255
|
# This function sets the list of handlers for the event.
|
217
256
|
def handlers_are(handlers)
|
218
|
-
|
219
|
-
|
220
|
-
event_handlers = @handlers
|
257
|
+
@@handlers ||= []
|
258
|
+
@@handlers.concat(handlers)
|
221
259
|
|
222
|
-
define_method('_handlers', -> {
|
260
|
+
define_method('_handlers', -> { @@handlers })
|
223
261
|
end
|
224
262
|
|
225
263
|
# This function sets the write event function for the event.
|
@@ -229,11 +267,10 @@ module Evnt
|
|
229
267
|
|
230
268
|
# This function is used to add a new handler to the event from the external.
|
231
269
|
def add_handler(handler)
|
232
|
-
|
233
|
-
|
234
|
-
event_handlers = @handlers
|
270
|
+
@@handlers ||= []
|
271
|
+
@@handlers.push(handler)
|
235
272
|
|
236
|
-
define_method('_handlers', -> {
|
273
|
+
define_method('_handlers', -> { @@handlers })
|
237
274
|
end
|
238
275
|
|
239
276
|
end
|
data/lib/evnt/version.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
<%= ' ' * (@event_modules.length + 1) %>name_is :<%= @event_name %>
|
9
9
|
<% unless @event_attributes.blank? %>
|
10
|
-
<%= ' ' * (@event_modules.length + 1) %>
|
10
|
+
<%= ' ' * (@event_modules.length + 1) %>payload_attributes_are <%= @event_attributes %>
|
11
11
|
<% end %>
|
12
12
|
<%= ' ' * @event_modules.length %>end
|
13
13
|
<% @event_modules.each_with_index do |_module_name, index| %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evnt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ideonetwork
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
|
104
|
-
rubygems_version: 2.7.3
|
103
|
+
rubygems_version: 3.0.6
|
105
104
|
signing_key:
|
106
105
|
specification_version: 4
|
107
106
|
summary: CQRS and Event Driven Development architecture for Ruby
|