Class: Messaging::Message::Metadata
- Inherits:
-
Object
- Object
- Messaging::Message::Metadata
- Includes:
- Schema::DataStructure
- Defined in:
- lib/messaging/message/metadata.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
- .causation_attribute_names ⇒ Object
- .origin_attribute_names ⇒ Object
- .source_attribute_names ⇒ Object
- .transient_attributes ⇒ Object
- .workflow_attribute_names ⇒ Object
Instance Method Summary collapse
- #causation_message_identifier ⇒ Object (also: #causation_identifier)
- #clear_local_properties ⇒ Object
- #clear_properties ⇒ Object
- #clear_reply_stream_name ⇒ Object
- #correlated?(stream_name) ⇒ Boolean (also: #correlates?)
- #delete_local_property(name) ⇒ Object
- #delete_property(name) ⇒ Object
- #follow(preceding_metadata) ⇒ Object
- #follows?(preceding_metadata) ⇒ Boolean
- #get_local_property(name) ⇒ Object
- #get_property(name) ⇒ Object
- #identifier ⇒ Object (also: #source_message_identifier)
- #reply? ⇒ Boolean
- #set_local_property(name, value) ⇒ Object
- #set_property(name, value) ⇒ Object
Class Method Details
.causation_attribute_names ⇒ Object
204 205 206 207 208 209 210 |
# File 'lib/messaging/message/metadata.rb', line 204 def self.causation_attribute_names [ :causation_message_stream_name, :causation_message_position, :causation_message_global_position ] end |
.origin_attribute_names ⇒ Object
212 213 214 215 216 217 |
# File 'lib/messaging/message/metadata.rb', line 212 def self.origin_attribute_names [ :correlation_stream_name, :reply_stream_name ] end |
.source_attribute_names ⇒ Object
196 197 198 199 200 201 202 |
# File 'lib/messaging/message/metadata.rb', line 196 def self.source_attribute_names [ :stream_name, :position, :global_position ] end |
.transient_attributes ⇒ Object
223 224 225 226 227 228 229 230 |
# File 'lib/messaging/message/metadata.rb', line 223 def self.transient_attributes [ :stream_name, :position, :global_position, :time ] end |
.workflow_attribute_names ⇒ Object
219 220 221 |
# File 'lib/messaging/message/metadata.rb', line 219 def self.workflow_attribute_names causation_attribute_names + origin_attribute_names end |
Instance Method Details
#causation_message_identifier ⇒ Object Also known as: causation_identifier
49 50 51 52 |
# File 'lib/messaging/message/metadata.rb', line 49 def return nil if .nil? || .nil? "#{causation_message_stream_name}/#{causation_message_position}" end |
#clear_local_properties ⇒ Object
192 193 194 |
# File 'lib/messaging/message/metadata.rb', line 192 def clear_local_properties local_properties.clear end |
#clear_properties ⇒ Object
162 163 164 |
# File 'lib/messaging/message/metadata.rb', line 162 def clear_properties properties.clear end |
#clear_reply_stream_name ⇒ Object
113 114 115 |
# File 'lib/messaging/message/metadata.rb', line 113 def clear_reply_stream_name self.reply_stream_name = nil end |
#correlated?(stream_name) ⇒ Boolean Also known as: correlates?
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/messaging/message/metadata.rb', line 121 def (stream_name) correlation_stream_name = self.correlation_stream_name return false if correlation_stream_name.nil? stream_name = Category.normalize(stream_name) if MessageStore::StreamName.category?(stream_name) correlation_stream_name = MessageStore::StreamName.get_category(correlation_stream_name) end correlation_stream_name == stream_name end |
#delete_local_property(name) ⇒ Object
184 185 186 187 188 189 190 |
# File 'lib/messaging/message/metadata.rb', line 184 def delete_local_property(name) if not name.is_a?(Symbol) raise Error, "Local property name must be a symbol: #{name.inspect}" end local_properties.delete(name) end |
#delete_property(name) ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/messaging/message/metadata.rb', line 154 def delete_property(name) if not name.is_a?(Symbol) raise Error, "Property name must be a symbol: #{name.inspect}" end properties.delete(name) end |
#follow(preceding_metadata) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/messaging/message/metadata.rb', line 55 def follow() self. = .stream_name self. = .position self. = .global_position self.correlation_stream_name = .correlation_stream_name self.reply_stream_name = .reply_stream_name .properties.each do |name, value| properties[name] = value end end |
#follows?(preceding_metadata) ⇒ Boolean
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/messaging/message/metadata.rb', line 69 def follows?() if .nil? && .stream_name.nil? return false end if != .stream_name return false end if .nil? && .position.nil? return false end if != .position return false end if .nil? && .global_position.nil? return false end if != .global_position return false end if not .correlation_stream_name.nil? if correlation_stream_name != .correlation_stream_name return false end end if not .reply_stream_name.nil? if reply_stream_name != .reply_stream_name return false end end true end |
#get_local_property(name) ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/messaging/message/metadata.rb', line 176 def get_local_property(name) if not name.is_a?(Symbol) raise Error, "Local property name must be a symbol: #{name.inspect}" end local_properties[name] end |
#get_property(name) ⇒ Object
146 147 148 149 150 151 152 |
# File 'lib/messaging/message/metadata.rb', line 146 def get_property(name) if not name.is_a?(Symbol) raise Error, "Property name must be a symbol: #{name.inspect}" end properties[name] end |
#identifier ⇒ Object Also known as: source_message_identifier
43 44 45 46 |
# File 'lib/messaging/message/metadata.rb', line 43 def identifier return nil if stream_name.nil? || position.nil? "#{stream_name}/#{position}" end |
#reply? ⇒ Boolean
117 118 119 |
# File 'lib/messaging/message/metadata.rb', line 117 def reply? !reply_stream_name.nil? end |
#set_local_property(name, value) ⇒ Object
166 167 168 169 170 171 172 173 174 |
# File 'lib/messaging/message/metadata.rb', line 166 def set_local_property(name, value) if not name.is_a?(Symbol) raise Error, "Local property name must be a symbol: #{name.inspect}" end local_properties[name] = value value end |
#set_property(name, value) ⇒ Object
136 137 138 139 140 141 142 143 144 |
# File 'lib/messaging/message/metadata.rb', line 136 def set_property(name, value) if not name.is_a?(Symbol) raise Error, "Property name must be a symbol: #{name.inspect}" end properties[name] = value value end |