Sha256: c079d1d665bd9761dcf9e2a9d0c4c0410c69b6b7171ff337302bbe42226e6732
Contents?: true
Size: 960 Bytes
Versions: 9
Compression:
Stored size: 960 Bytes
Contents
# frozen_string_literal: true module Mimi module Messaging # # A Message is a Hash and additional headers structure. # class Message < Hash attr_reader :headers # Creates a Message out of Hash or another Message. # # @param message_or_hash [Hash,Message] # @param headers [Hash,nil] additional headers to attach to the message # def initialize(message_or_hash, headers = nil) unless message_or_hash.is_a?(Hash) # or a Message raise ArgumentError, "Message or Hash is expected as argument" end # copy attributes message_or_hash.each { |k, v| self[k] = v.dup } # copy headers headers ||= {} if message_or_hash.is_a?(Mimi::Messaging::Message) @headers = message_or_hash.headers.merge(headers) else @headers = headers end end end # class Message end # module Messaging end # module Mimi
Version data entries
9 entries across 9 versions & 1 rubygems