evt-messaging 2.6.0.0 → 2.7.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
  SHA256:
3
- metadata.gz: bdc052cd505024a0dc1c9ee66b8c7bf9233f1deb8efb4cc07f8bc67ac37dc1ca
4
- data.tar.gz: 25087356a05e7d159345ef0f268d2fcb671dcac86f931236c7be25a49dd003d7
3
+ metadata.gz: d22a40f19386098d8d266f77e69a6c794324d30f018e96a4993eab0c5cfc20e1
4
+ data.tar.gz: 8d523d0b69b432eed9e06e8e24731a77f14809fd86df46aed900feb90b2d4e9c
5
5
  SHA512:
6
- metadata.gz: cdf114d68c3a8102adf5a675eb2b784e36e51882b08b66e9ffeffeaf5cc0597741ae70a2326b6d14db69c3ab2ed5c9a41566f98eadaae3fec653617fa88ce067
7
- data.tar.gz: 9438c70a8643db857dd6102f2ae22c5f4ca71e4dde416096a303e267a89c8ed0b6c71730fde5f9c1a5c1ab66db65c9eaad19f2128a6cab2c2e6a8584cf8a3a7c
6
+ metadata.gz: ea96206a951ad33ef9b7e7d52db38e9f9584adaa66d898cf77579608e16ebff7b597017d770bf143048809b964d3dd5d90da4bef7ab262516506ab0cfc53881c
7
+ data.tar.gz: 8655511a3ae29570de973f79b5cfd535be9f701fdd6c2a7625fb4e9f746315bcb377b35c560c18563e482af2f53096b2215dcca79956361c48e868f65d6e98c0
@@ -60,63 +60,6 @@ module Messaging
60
60
  end
61
61
  end
62
62
  end
63
-
64
- module SessionArgument
65
- class Example
66
- include Messaging::Handle
67
-
68
- attr_accessor :session
69
-
70
- def configure(session: nil)
71
- self.session = session
72
- end
73
- end
74
-
75
- module Anomaly
76
- module Required
77
- class Example
78
- include Messaging::Handle
79
-
80
- def configure(session:)
81
- end
82
- end
83
- end
84
-
85
- module Positional
86
- class Example
87
- include Messaging::Handle
88
-
89
- def configure(session)
90
- end
91
- end
92
-
93
- module Optional
94
- class Example
95
- include Messaging::Handle
96
-
97
- def configure(session=nil)
98
- end
99
- end
100
- end
101
- end
102
- end
103
- end
104
-
105
- module Settings
106
- Error = Class.new(RuntimeError)
107
-
108
- class Example
109
- include Messaging::Handle
110
-
111
- setting :some_setting
112
-
113
- attr_accessor :some_other_setting
114
-
115
- def handle(message_data)
116
- raise Settings::Error if some_setting.nil?
117
- end
118
- end
119
- end
120
63
  end
121
64
  end
122
65
  end
@@ -6,7 +6,6 @@ module Messaging
6
6
  cls.class_exec do
7
7
  include Dependency
8
8
  include Virtual
9
- include Settings::Setting
10
9
 
11
10
  def handler_logger
12
11
  @handler_logger ||= Log.get(self)
@@ -26,37 +25,49 @@ module Messaging
26
25
  end
27
26
 
28
27
  module Build
28
+ Error = Class.new(RuntimeError)
29
+
29
30
  def build(strict: nil, session: nil, settings: nil)
30
31
  instance = new
31
32
  instance.strict = strict
32
33
 
33
- if not settings.nil?
34
- settings.set(instance)
34
+ arguments = {}
35
+
36
+ if Build.send_session?(session, instance)
37
+ arguments[:session] = session
35
38
  end
36
39
 
37
- if Build.configure_session?(instance)
38
- instance.configure(session: session)
39
- else
40
- instance.configure
40
+ if Build.send_settings?(settings, instance)
41
+ arguments[:settings] = settings
41
42
  end
42
43
 
44
+ instance.configure(**arguments)
45
+
43
46
  instance
44
47
  end
45
48
 
46
- def self.configure_session?(instance)
49
+ def self.send_session?(session, instance)
50
+ configure?(instance, :session) && !session.nil?
51
+ end
52
+
53
+ def self.send_settings?(settings, instance)
54
+ configure?(instance, :settings) && !settings.nil?
55
+ end
56
+
57
+ def self.configure?(instance, parameter_name)
47
58
  configure_method = instance.method(:configure)
48
59
 
49
60
  parameter_type, _ = configure_method.parameters.find do |type, name|
50
- name == :session
61
+ name == parameter_name
51
62
  end
52
63
 
53
64
  return false if parameter_type.nil?
54
65
 
55
- return true if parameter_type == :key
66
+ return true if [:key, :keyreq].include?(parameter_type)
56
67
 
57
- error_message = "Optional session parameter of configure is not a keyword argument (Type: #{parameter_type.inspect})"
68
+ error_message = "Incorrect definition of handler's configure method. The #{parameter_name} parameter must be a keyword argument (Handler: #{instance.class}, Parameter Type: #{parameter_type.inspect})"
58
69
  handler_logger.error(tag: :handle) { error_message }
59
- raise ArgumentError, error_message
70
+ raise Error, error_message
60
71
  end
61
72
 
62
73
  def self.handler_logger
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-messaging
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0.0
4
+ version: 2.7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-08 00:00:00.000000000 Z
11
+ date: 2021-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-message_store