Class: BotMob::OutboundMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/bot_mob/outbound_message.rb

Overview

# BotMob::OutboundMessage

Strucutred data for all messages leaving your bot

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ OutboundMessage

Returns a new instance of OutboundMessage.



8
9
10
11
12
# File 'lib/bot_mob/outbound_message.rb', line 8

def initialize(**options)
  @network ||= options[:network]
  @inbound = options[:inbound]
  @body = options[:body]
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



6
7
8
# File 'lib/bot_mob/outbound_message.rb', line 6

def body
  @body
end

#inboundObject (readonly)

Returns the value of attribute inbound.



6
7
8
# File 'lib/bot_mob/outbound_message.rb', line 6

def inbound
  @inbound
end

#networkObject (readonly)

Returns the value of attribute network.



6
7
8
# File 'lib/bot_mob/outbound_message.rb', line 6

def network
  @network
end

Class Method Details

.prepare(message, options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/bot_mob/outbound_message.rb', line 14

def self.prepare(message, options = {})
  return message if message.is_a?(BotMob::OutboundMessage)

  target_network = options[:inbound].network
  message_delegate(target_network).new(options.merge(body: message))
end