Class: Pheromone::Messaging::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/pheromone/messaging/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(topic:, blob:, metadata: {}, options: {}, encoder:, message_format:, embed_blob:) ⇒ Message

Returns a new instance of Message.



5
6
7
8
9
10
11
12
13
# File 'lib/pheromone/messaging/message.rb', line 5

def initialize(topic:, blob:, metadata: {}, options: {}, encoder:, message_format:, embed_blob:)
  @topic = topic
  @blob = blob
  @options = options || {}
  @metadata =  || {}
  @encoder = encoder
  @message_format = message_format
  @embed_blob = embed_blob
end

Instance Attribute Details

#blobObject (readonly)

Returns the value of attribute blob.



15
16
17
# File 'lib/pheromone/messaging/message.rb', line 15

def blob
  @blob
end

#metadataObject (readonly)

Returns the value of attribute metadata.



15
16
17
# File 'lib/pheromone/messaging/message.rb', line 15

def 
  @metadata
end

#optionsObject (readonly)

Returns the value of attribute options.



15
16
17
# File 'lib/pheromone/messaging/message.rb', line 15

def options
  @options
end

#topicObject (readonly)

Returns the value of attribute topic.



15
16
17
# File 'lib/pheromone/messaging/message.rb', line 15

def topic
  @topic
end

Instance Method Details

#send!Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/pheromone/messaging/message.rb', line 17

def send!
  WaterDrop::SyncProducer.call(
    MessageFormatter.new(
      message,
      @encoder,
      @message_format
    ).format,
    { topic: topic.to_s }.merge!(options)
  )
end