Module: Whatsapp::MessageTemplates::ValueObject

Overview

Shared behaviour for the nested value objects that make up a template payload: components, buttons, carousel cards, and library inputs.

Pulls together the three things every one of them needs — ActiveModel validations, the class-level .serialize shorthand used throughout this gem, and a couple of validation helpers — so they are declared once rather than re-stated in each Base.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ void

This method returns an undefined value.

Parameters:

  • base (Class)


15
16
17
18
# File 'lib/ruby/whatsapp/message_templates/value_object.rb', line 15

def self.included(base)
  base.include(ActiveModel::Validations)
  base.extend(ClassMethods)
end

Instance Method Details

#serializeHash

Returns The API payload for this object.

Returns:

  • (Hash)

    The API payload for this object.

Raises:

  • (NotImplementedError)


29
30
31
# File 'lib/ruby/whatsapp/message_templates/value_object.rb', line 29

def serialize
  raise NotImplementedError, "Subclasses must implement the serialize method"
end