Class: CommandTower::Messaging::Rendering::InboxDocument
- Inherits:
-
Data
- Object
- Data
- CommandTower::Messaging::Rendering::InboxDocument
- Defined in:
- app/services/command_tower/messaging/rendering/inbox_document.rb,
app/services/command_tower/messaging/rendering/inbox_document.rb
Overview
Reopened (rather than defined inside the Data.define block) so that
SCHEMA_V1 and .build attach to InboxDocument under normal
lexical constant scoping — a block passed to Data.define does not
change the lexical scope for constant assignment the way class ... end does.
Defined Under Namespace
Classes: Builder
Constant Summary collapse
- SCHEMA_V1 =
"inbox_document_v1"
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Class Method Summary collapse
- .build(blocks:) ⇒ Object
-
.compose {|builder| ... } ⇒ Object
Small pure-Ruby authoring DSL (Rich Messaging Slice 2.5 revision — replaces
inbox_document.json.erbentirely; see artifacts/visual-improvements/rich-messaging/authority/RICH_MESSAGING_RUBY_INBOX_DEFINITION_DISCOVERY.md).
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks
17 18 19 |
# File 'app/services/command_tower/messaging/rendering/inbox_document.rb', line 17 def blocks @blocks end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema
17 18 19 |
# File 'app/services/command_tower/messaging/rendering/inbox_document.rb', line 17 def schema @schema end |
Class Method Details
.build(blocks:) ⇒ Object
27 28 29 30 31 32 |
# File 'app/services/command_tower/messaging/rendering/inbox_document.rb', line 27 def self.build(blocks:) raise ArgumentError, "blocks must be an Array" unless blocks.is_a?(Array) raise ArgumentError, "arbitrary hashes are not accepted as blocks entries" if blocks.any? { |b| !b.is_a?(Hash) } new(schema: SCHEMA_V1, blocks: blocks.freeze).freeze end |
.compose {|builder| ... } ⇒ Object
Small pure-Ruby authoring DSL (Rich Messaging Slice 2.5 revision —
replaces inbox_document.json.erb entirely; see
artifacts/visual-improvements/rich-messaging/authority/RICH_MESSAGING_RUBY_INBOX_DEFINITION_DISCOVERY.md).
A notification-type Inbox document composer calls .compose and
authors an ordered document via exactly three methods:
doc.paragraph "..."
doc.cta "label", path: "/internal/route"
doc.cta "label", href: "https://external.example/..."
doc.presentation "pickem.make_picks", variant: :compact
cta takes exactly one of path: (an internal, origin-free
destination the host's own navigation owns) or href: (an
absolute external URL opened via the platform's normal external-
link handling). The composer — which already knows whether a
destination is its own app's route or a third-party URL — states
that intent explicitly via a typed destination, rather than
having the frontend infer it from an absolute URL (Slice 2.6.4;
see artifacts/visual-improvements/rich-messaging/plans/
2.6.4-ct-fe-inbox-navigation-capability.md).
presentation intentionally has no data:/props: argument at
all — the message type may only name a registered presentation
capability. Its data is composed separately, post-authoring, by
InboxDocumentRenderer and the registered presentation composer
(Rich Messaging Presentation Authority §8). There is no argument
slot to violate that boundary with.
60 61 62 63 64 |
# File 'app/services/command_tower/messaging/rendering/inbox_document.rb', line 60 def self.compose builder = Builder.new yield builder build(blocks: builder.blocks) end |