Class: MessageQuickly::Messaging::Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Message

Returns a new instance of Message.

Yields:

  • (_self)

Yield Parameters:



7
8
9
10
# File 'lib/message_quickly/messaging/message.rb', line 7

def initialize(options = {})
  options.each { |key, value| instance_variable_set("@#{key}", value) }
  yield self if block_given?
end

Instance Attribute Details

#attachmentObject

Returns the value of attribute attachment.



5
6
7
# File 'lib/message_quickly/messaging/message.rb', line 5

def attachment
  @attachment
end

#textObject

Returns the value of attribute text.



5
6
7
# File 'lib/message_quickly/messaging/message.rb', line 5

def text
  @text
end

Instance Method Details

#build_attachment(attachment_type) {|attachment| ... } ⇒ Object

Yields:



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/message_quickly/messaging/message.rb', line 12

def build_attachment(attachment_type)
  case attachment_type
  when :image
    self.attachment = MessageQuickly::Messaging::ImageAttachment.new
  when :generic_template
    self.attachment = MessageQuickly::Messaging::GenericTemplateAttachment.new
  when :button_template
    self.attachment = MessageQuickly::Messaging::ButtonTemplateAttachment.new
  when :receipt_template
    self.attachment = MessageQuickly::Messaging::ReceiptTemplateAttachment.new
  end
  yield attachment if block_given?
end

#to_hashObject



26
27
28
29
30
31
32
# File 'lib/message_quickly/messaging/message.rb', line 26

def to_hash
  if attachment
    { attachment: attachment.to_hash }
  else
    { text: text }
  end
end