Module: Whatsapp::MessageTemplates::ValueObject
- Included in:
- Button::Base, Button::Otp::SupportedApp, Component::Base, Component::Carousel::Card, ComponentSet, LibraryTemplate, LibraryTemplate::BodyInputs, LibraryTemplate::ButtonInputs, Template
- Defined in:
- lib/ruby/whatsapp/message_templates/value_object.rb
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
-
#serialize ⇒ Hash
The API payload for this object.
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
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
#serialize ⇒ Hash
Returns The API payload for this object.
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 |