evt-entity_projection 0.2.0.0 → 0.3.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
  SHA1:
3
- metadata.gz: 23f0bfd91feb804a12ce76a8b8ffa1e73c0e151b
4
- data.tar.gz: b850f77586e53b37be15bb17a7319e51063804f6
3
+ metadata.gz: d95cac2f4433102c6e103842c3090d76e15dfd7e
4
+ data.tar.gz: 8572642c0c05470a182a224b0a07e71c655bb05c
5
5
  SHA512:
6
- metadata.gz: 45c1e581a3dd61398dd2e1b376ad5a46937ac4f3d51a8eb0612b7a4b74e451ea5184c30df6f76eb00b5b403e4d278d95cfc1224c584e823cc37c878820c10fb1
7
- data.tar.gz: 38f9b9e8b044a010bee4026bd2492a8164560baa574920e7a5879ceef53dad85870acd44cfa6cd266d729acb7dca86ca494f62e7ccf0e846bca5f3ee3604b0c4
6
+ metadata.gz: 4f5ba73316e7ce808eebb093767ab1d7dbe3027e439872975a3b7cd4b5573fa3fdce4663b4646f251f29a65c2562300163682b1e429568183ce28cd17fd8d433
7
+ data.tar.gz: ab267dd0bf149334ae5e1b1551a9fc6d2aae78549b05ced35b78550ba6e8d318b4052b071dd954ac20466415b87a278f786ab2fe453982d78c3c95427414b6ac
@@ -1,5 +1,5 @@
1
1
  module EntityProjection
2
2
  module Controls
3
- EventData = Messaging::Controls::EventData
3
+ EventData = Messaging::Controls::MessageData
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@ module EntityProjection
7
7
  cls.extend Call
8
8
  cls.extend Info
9
9
  cls.extend ApplyMacro
10
- cls.extend MessageRegistry
10
+ cls.extend EventRegistry
11
11
  cls.extend EntityNameMacro
12
12
 
13
13
  virtual :configure
@@ -27,8 +27,8 @@ module EntityProjection
27
27
  module Info
28
28
  extend self
29
29
 
30
- def handler(message_or_event_data)
31
- name = handler_name(message_or_event_data)
30
+ def handler(event_or_event_data)
31
+ name = handler_name(event_or_event_data)
32
32
 
33
33
  if method_defined?(name)
34
34
  return name
@@ -37,17 +37,19 @@ module EntityProjection
37
37
  end
38
38
  end
39
39
 
40
- def handles?(message_or_event_data)
41
- method_defined? handler_name(message_or_event_data)
40
+ def handles?(event_or_event_data)
41
+ handler_name = self.handler_name(event_or_event_data)
42
+
43
+ method_defined?(handler_name)
42
44
  end
43
45
 
44
- def handler_name(message_or_event_data)
46
+ def handler_name(event_or_event_data)
45
47
  name = nil
46
48
 
47
- if message_or_event_data.is_a? EventSource::EventData::Read
48
- name = Messaging::Message::Info.canonize_name(message_or_event_data.type)
49
+ if event_or_event_data.is_a?(MessageStore::MessageData::Read)
50
+ name = Messaging::Message::Info.canonize_name(event_or_event_data.type)
49
51
  else
50
- name = message_or_event_data.message_name
52
+ name = event_or_event_data.message_name
51
53
  end
52
54
 
53
55
  "apply_#{name}"
@@ -61,17 +63,17 @@ module EntityProjection
61
63
  @logger ||= Log.get(self)
62
64
  end
63
65
 
64
- def apply_macro(message_class, &blk)
65
- define_apply_method(message_class, &blk)
66
- message_registry.register(message_class)
66
+ def apply_macro(event_class, &blk)
67
+ define_apply_method(event_class, &blk)
68
+ event_registry.register(event_class)
67
69
  end
68
70
  alias :apply :apply_macro
69
71
 
70
- def define_apply_method(message_class, &blk)
71
- apply_method_name = handler_name(message_class)
72
+ def define_apply_method(event_class, &blk)
73
+ apply_method_name = handler_name(event_class)
72
74
 
73
75
  if blk.nil?
74
- error_msg = "Handler for #{message_class.name} is not correctly defined. It must have a block."
76
+ error_msg = "Handler for #{event_class.name} is not correctly defined. It must have a block."
75
77
  logger.error { error_msg }
76
78
  raise Error, error_msg
77
79
  end
@@ -81,7 +83,7 @@ module EntityProjection
81
83
  apply_method = instance_method(apply_method_name)
82
84
 
83
85
  unless apply_method.arity == 1
84
- error_msg = "Handler for #{message_class.name} is not correctly defined. It can only have a single parameter."
86
+ error_msg = "Handler for #{event_class.name} is not correctly defined. It can only have a single parameter."
85
87
  logger.error { error_msg }
86
88
  raise Error, error_msg
87
89
  end
@@ -91,15 +93,15 @@ module EntityProjection
91
93
  end
92
94
 
93
95
  module Call
94
- def call(entity, message_or_event_data)
96
+ def call(entity, event_or_event_data)
95
97
  instance = build(entity)
96
- instance.(message_or_event_data)
98
+ instance.(event_or_event_data)
97
99
  end
98
100
  end
99
101
 
100
- module MessageRegistry
101
- def message_registry
102
- @message_registry ||= Messaging::MessageRegistry.new
102
+ module EventRegistry
103
+ def event_registry
104
+ @event_registry ||= Messaging::MessageRegistry.new
103
105
  end
104
106
  end
105
107
 
@@ -112,28 +114,28 @@ module EntityProjection
112
114
  alias :entity_name :entity_name_macro
113
115
  end
114
116
 
115
- def call(message_or_event_data)
116
- if message_or_event_data.is_a? Messaging::Message
117
- apply_message(message_or_event_data)
117
+ def call(event_or_event_data)
118
+ if event_or_event_data.is_a?(Messaging::Message)
119
+ apply_event(event_or_event_data)
118
120
  else
119
- apply_event_data(message_or_event_data)
121
+ apply_event_data(event_or_event_data)
120
122
  end
121
123
  end
122
124
 
123
- def apply_message(message)
124
- logger.trace(tags: [:apply, :message]) { "Applying message (Message class: #{message.class.name})" }
125
- logger.trace(tags: [:data, :message, :apply]) { message.pretty_inspect }
125
+ def apply_event(event)
126
+ logger.trace(tags: [:apply, :message]) { "Applying event (Event class: #{event.class.name})" }
127
+ logger.trace(tags: [:data, :message, :apply]) { event.pretty_inspect }
126
128
 
127
- handler = self.class.handler(message)
129
+ handler = self.class.handler(event)
128
130
 
129
131
  unless handler.nil?
130
- public_send(handler, message)
132
+ public_send(handler, event)
131
133
  end
132
134
 
133
- logger.info(tags: [:apply, :message]) { "Applied message (Message class: #{message.class.name})" }
134
- logger.trace(tags: [:data, :message, :apply]) { message.pretty_inspect }
135
+ logger.info(tags: [:apply, :message]) { "Applied event (Event class: #{event.class.name})" }
136
+ logger.trace(tags: [:data, :message, :apply]) { event.pretty_inspect }
135
137
 
136
- message
138
+ event
137
139
  end
138
140
 
139
141
  def apply_event_data(event_data)
@@ -145,9 +147,9 @@ module EntityProjection
145
147
  handler = self.class.handler(event_data)
146
148
 
147
149
  unless handler.nil?
148
- message_name = Messaging::Message::Info.canonize_name(event_data.type)
149
- message_class = self.class.message_registry.get(message_name)
150
- res = Messaging::Message::Import.(event_data, message_class)
150
+ event_name = Messaging::Message::Info.canonize_name(event_data.type)
151
+ event_class = self.class.event_registry.get(event_name)
152
+ res = Messaging::Message::Import.(event_data, event_class)
151
153
  public_send(handler, res)
152
154
  else
153
155
  if respond_to?(:apply)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-entity_projection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.0
4
+ version: 0.3.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: 2017-04-10 00:00:00.000000000 Z
11
+ date: 2017-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-messaging
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: evt-message_store-postgres
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: " "
42
56
  email: opensource@eventide-project.org
43
57
  executables: []