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.

renders_as:

:text the resolver returns a String key. The pipeline records it, emits
    a nonce-protected placeholder, and later substitutes the resolved
    HTML-escaped value. Variables use this.
:html 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 :text chips resolve in the
    same pass. Snippets use this. Bounded by max_fragment_depth.

resolve: ->(node, context) { ... } returning a key (:text) or rich content (:html), 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

#renders_asObject

Returns the value of attribute renders_as

Returns:

  • (Object)

    the current value of renders_as



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

def renders_as
  @renders_as
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

#renders_as_html?Boolean

Returns:

  • (Boolean)


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

def renders_as_html? = renders_as == :html

#renders_as_text?Boolean

Returns:

  • (Boolean)


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

def renders_as_text? = renders_as == :text