Class: Messaging::Message::Metadata
- Inherits:
-
Object
- Object
- Messaging::Message::Metadata
- Includes:
- Schema::DataStructure
- Defined in:
- lib/messaging/message/metadata.rb,
lib/messaging/message/metadata/property.rb
Defined Under Namespace
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_properties ⇒ Object
- #clear_reply_stream_name ⇒ Object
- #correlated?(stream_name) ⇒ Boolean (also: #correlates?)
- #delete_property(name) ⇒ Object
- #follow(preceding_metadata) ⇒ Object
- #follows?(preceding_metadata) ⇒ Boolean
- #get_property(name) ⇒ Object
- #identifier ⇒ Object (also: #source_message_identifier)
- #reply? ⇒ Boolean
- #set_local_property(name, value) ⇒ Object
- #set_property(name, value, local: nil) ⇒ Object
Class Method Details
.causation_attribute_names ⇒ Object
192 193 194 195 196 197 198 |
# File 'lib/messaging/message/metadata.rb', line 192 def self.causation_attribute_names [ :causation_message_stream_name, :causation_message_position, :causation_message_global_position ] end |
.origin_attribute_names ⇒ Object
200 201 202 203 204 205 |
# File 'lib/messaging/message/metadata.rb', line 200 def self.origin_attribute_names [ :correlation_stream_name, :reply_stream_name ] end |
.source_attribute_names ⇒ Object
184 185 186 187 188 189 190 |
# File 'lib/messaging/message/metadata.rb', line 184 def self.source_attribute_names [ :stream_name, :position, :global_position ] end |
.transient_attributes ⇒ Object
211 212 213 214 215 216 217 218 |
# File 'lib/messaging/message/metadata.rb', line 211 def self.transient_attributes [ :stream_name, :position, :global_position, :time ] end |
.workflow_attribute_names ⇒ Object
207 208 209 |
# File 'lib/messaging/message/metadata.rb', line 207 def self.workflow_attribute_names causation_attribute_names + origin_attribute_names end |
Instance Method Details
#causation_message_identifier ⇒ Object Also known as: causation_identifier
48 49 50 51 |
# File 'lib/messaging/message/metadata.rb', line 48 def return nil if .nil? || .nil? "#{}/#{}" end |
#clear_properties ⇒ Object
180 181 182 |
# File 'lib/messaging/message/metadata.rb', line 180 def clear_properties properties.clear end |
#clear_reply_stream_name ⇒ Object
116 117 118 |
# File 'lib/messaging/message/metadata.rb', line 116 def clear_reply_stream_name self.reply_stream_name = nil end |
#correlated?(stream_name) ⇒ Boolean Also known as: correlates?
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/messaging/message/metadata.rb', line 124 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_property(name) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/messaging/message/metadata.rb', line 168 def delete_property(name) if not name.is_a?(String) raise Error, "Property name must be a string: #{name.inspect}" end i = properties.index { |property| property.name == name } return nil if i.nil? properties.delete_at(i).value end |
#follow(preceding_metadata) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/messaging/message/metadata.rb', line 54 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 |property| if property.local? next end properties << property.dup end end |
#follows?(preceding_metadata) ⇒ Boolean
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 112 113 114 |
# File 'lib/messaging/message/metadata.rb', line 72 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_property(name) ⇒ Object
159 160 161 162 163 164 165 166 |
# File 'lib/messaging/message/metadata.rb', line 159 def get_property(name) if not name.is_a?(String) raise Error, "Property name must be a string: #{name.inspect}" end property = properties.find { |property| property.name == name } property&.value end |
#identifier ⇒ Object Also known as: source_message_identifier
42 43 44 45 |
# File 'lib/messaging/message/metadata.rb', line 42 def identifier return nil if stream_name.nil? || position.nil? "#{stream_name}/#{position}" end |
#reply? ⇒ Boolean
120 121 122 |
# File 'lib/messaging/message/metadata.rb', line 120 def reply? !reply_stream_name.nil? end |
#set_local_property(name, value) ⇒ Object
155 156 157 |
# File 'lib/messaging/message/metadata.rb', line 155 def set_local_property(name, value) set_property(name, value, local: true) end |
#set_property(name, value, local: nil) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/messaging/message/metadata.rb', line 139 def set_property(name, value, local: nil) if not name.is_a?(String) raise Error, "Property name must be a string: #{name.inspect}" end local ||= false delete_property(name) property = Property.new(name, value, local) properties << property property end |