class Line::Message::Builder::Flex::Partial
The Partial class is an abstract base for creating reusable snippets of Flex Message content. To define a partial, create a new class that inherits from Partial and implements the call instance method.
Within the call method, you can use the standard Flex Message builder DSL methods (e.g., text, box, button) as if you were directly inside the component where the partial is being rendered. This is possible because the Partial instance delegates unknown method calls to the component instance that is rendering it (passed as context during initialization).
Subclass and implement call to create a concrete partial.
See also:
-
HasPartialfor how to render partials
Public Class Methods
Source
# File lib/line/message/builder/flex/partial.rb, line 90 def initialize(context:) @context = context # The component (e.g., Box, Bubble) rendering this partial end
Initializes a new Partial instance. This is typically called by the HasPartial#partial! method.
Public Instance Methods
Source
# File lib/line/message/builder/flex/partial.rb, line 107 def call(*) raise NotImplementedError, "The #{self.class.name} class must implement the #call method to define its content." end
This method must be implemented by subclasses to define the content of the partial. Inside this method, use the Flex Message builder DSL methods (e.g., text "Hello", button { ... }) which will be delegated to the rendering context.
Any arguments passed to partial! as assigns are available via context.assigns or directly if the rendering context’s method_missing handles assigns lookup (as Line::Message::Builder::Context does).
Arguments passed from the partial! call’s assigns can be explicitly defined as parameters here, or accessed via context.assigns.
Raises NotImplementedError if a subclass does not implement this method.