Class: Mantle::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/mantle/message.rb,
lib/mantle/testing.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel) ⇒ Message

Returns a new instance of Message.



6
7
8
9
10
# File 'lib/mantle/message.rb', line 6

def initialize(channel)
  @channel = channel
  @message_bus = Mantle::MessageBus.new
  @catch_up = Mantle::CatchUp.new
end

Instance Attribute Details

#catch_up=(value) ⇒ Object

Sets the attribute catch_up

Parameters:

  • value

    the value to set the attribute catch_up to.



4
5
6
# File 'lib/mantle/message.rb', line 4

def catch_up=(value)
  @catch_up = value
end

#channelObject (readonly)

Returns the value of attribute channel.



3
4
5
# File 'lib/mantle/message.rb', line 3

def channel
  @channel
end

#message_bus=(value) ⇒ Object

Sets the attribute message_bus

Parameters:

  • value

    the value to set the attribute message_bus to.



4
5
6
# File 'lib/mantle/message.rb', line 4

def message_bus=(value)
  @message_bus = value
end

Instance Method Details

#publish(message) ⇒ Object



12
13
14
15
16
# File 'lib/mantle/message.rb', line 12

def publish(message)
  message = message.merge(__MANTLE__: { message_source: whoami }) if whoami
  message_bus.publish(channel, message)
  catch_up.add_message(channel, message)
end