class MessageQuickly::Messaging::Element

Attributes

buttons[RW]
image_url[RW]
subtitle[RW]
title[RW]

Public Class Methods

new(params = {}) click to toggle source
Calls superclass method MessageQuickly::Messaging::Base::new
# File lib/message_quickly/messaging/element.rb, line 7
def initialize(params = {})
  self.buttons ||= []
  super(params)
end

Public Instance Methods

build_button(button_type) { |button| ... } click to toggle source
# File lib/message_quickly/messaging/element.rb, line 12
def build_button(button_type)
  case button_type
  when :web_url
    button = WebUrlButton.new
  when :postback
    button = PostbackButton.new
  when :account_link
    button = AccountLinkButton.new
  end
  buttons << button.tap { |button| yield button }
end
to_hash() click to toggle source
# File lib/message_quickly/messaging/element.rb, line 24
def to_hash
  {
    title: title,
    image_url: image_url,
    subtitle: subtitle,
    buttons: buttons.collect { |button| button.to_hash }
  }
end