class Messaging::Message::Metadata

Public Class Methods

causation_attribute_names() click to toggle source
# 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() click to toggle source
# File lib/messaging/message/metadata.rb, line 212
def self.origin_attribute_names
  [
    :correlation_stream_name,
    :reply_stream_name
  ]
end
source_attribute_names() click to toggle source
# File lib/messaging/message/metadata.rb, line 196
def self.source_attribute_names
  [
    :stream_name,
    :position,
    :global_position
  ]
end
transient_attributes() click to toggle source
# File lib/messaging/message/metadata.rb, line 223
def self.transient_attributes
  [
    :stream_name,
    :position,
    :global_position,
    :time
  ]
end
workflow_attribute_names() click to toggle source
# File lib/messaging/message/metadata.rb, line 219
def self.workflow_attribute_names
  causation_attribute_names + origin_attribute_names
end

Public Instance Methods

causation_identifier()
causation_message_identifier() click to toggle source
# File lib/messaging/message/metadata.rb, line 49
def causation_message_identifier
  return nil if causation_message_stream_name.nil? || causation_message_position.nil?
  "#{causation_message_stream_name}/#{causation_message_position}"
end
Also aliased as: causation_identifier
clear_local_properties() click to toggle source
# File lib/messaging/message/metadata.rb, line 192
def clear_local_properties
  local_properties.clear
end
clear_properties() click to toggle source
# File lib/messaging/message/metadata.rb, line 162
def clear_properties
  properties.clear
end
clear_reply_stream_name() click to toggle source
# File lib/messaging/message/metadata.rb, line 113
def clear_reply_stream_name
  self.reply_stream_name = nil
end
correlated?(stream_name) click to toggle source
# File lib/messaging/message/metadata.rb, line 121
def correlated?(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
Also aliased as: correlates?
correlates?(stream_name)
Alias for: correlated?
delete_local_property(name) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/messaging/message/metadata.rb, line 55
def follow(preceding_metadata)
  self.causation_message_stream_name = preceding_metadata.stream_name
  self.causation_message_position = preceding_metadata.position
  self.causation_message_global_position = preceding_metadata.global_position

  self.correlation_stream_name = preceding_metadata.correlation_stream_name

  self.reply_stream_name = preceding_metadata.reply_stream_name

  preceding_metadata.properties.each do |name, value|
    properties[name] = value
  end
end
follows?(preceding_metadata) click to toggle source
# File lib/messaging/message/metadata.rb, line 69
def follows?(preceding_metadata)
  if causation_message_stream_name.nil? && preceding_metadata.stream_name.nil?
    return false
  end

  if causation_message_stream_name != preceding_metadata.stream_name
    return false
  end


  if causation_message_position.nil? && preceding_metadata.position.nil?
    return false
  end

  if causation_message_position != preceding_metadata.position
    return false
  end


  if causation_message_global_position.nil? && preceding_metadata.global_position.nil?
    return false
  end

  if causation_message_global_position != preceding_metadata.global_position
    return false
  end


  if not preceding_metadata.correlation_stream_name.nil?
    if correlation_stream_name != preceding_metadata.correlation_stream_name
      return false
    end
  end


  if not preceding_metadata.reply_stream_name.nil?
    if reply_stream_name != preceding_metadata.reply_stream_name
      return false
    end
  end

  true
end
get_local_property(name) click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/messaging/message/metadata.rb, line 43
def identifier
  return nil if stream_name.nil? || position.nil?
  "#{stream_name}/#{position}"
end
Also aliased as: source_message_identifier
reply?() click to toggle source
# File lib/messaging/message/metadata.rb, line 117
def reply?
  !reply_stream_name.nil?
end
set_local_property(name, value) click to toggle source
# 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) click to toggle source
# 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
source_message_identifier()
Alias for: identifier