Class: LexxyVariables::AttachmentType

Inherits:
Struct
  • Object
show all
Defined in:
lib/lexxy_variables/attachment_type.rb

Overview

Describes one kind of attachment chip the pipeline knows how to resolve. A chip is identified solely by its content-type, which the editor always writes and the model always persists.

phase:

:value    the resolver returns a String key. The pipeline records it, emits
        a nonce-protected placeholder, and later substitutes the resolved
        HTML-escaped value. Safe by construction. Variables use this.
:fragment the resolver returns rich content (ActionText content, RichText,
        or an HTML String) spliced into the document BEFORE sanitization,
        so the sanitizer cleans it and inner :value chips resolve in the
        same pass. Snippets use this. Bounded by max_fragment_depth.

resolve: ->(node, context) { ... } returning a key (:value) or rich content (:fragment), or nil to drop the chip.

label: optional short type name (e.g. "Variable", "Snippet"). The prompt shows it as a badge only when the list mixes more than one type, so users can tell them apart without noise when there is only one. nil shows no badge.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type

Returns:

  • (Object)

    the current value of content_type



21
22
23
# File 'lib/lexxy_variables/attachment_type.rb', line 21

def content_type
  @content_type
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



21
22
23
# File 'lib/lexxy_variables/attachment_type.rb', line 21

def label
  @label
end

#phaseObject

Returns the value of attribute phase

Returns:

  • (Object)

    the current value of phase



21
22
23
# File 'lib/lexxy_variables/attachment_type.rb', line 21

def phase
  @phase
end

#resolveObject

Returns the value of attribute resolve

Returns:

  • (Object)

    the current value of resolve



21
22
23
# File 'lib/lexxy_variables/attachment_type.rb', line 21

def resolve
  @resolve
end

Instance Method Details

#fragment?Boolean

Returns:

  • (Boolean)


23
# File 'lib/lexxy_variables/attachment_type.rb', line 23

def fragment? = phase == :fragment

#value?Boolean

Returns:

  • (Boolean)


22
# File 'lib/lexxy_variables/attachment_type.rb', line 22

def value?    = phase == :value