Class: Lutaml::Lml::Types::TextType

Inherits:
Model::Type::String
  • Object
show all
Defined in:
lib/lutaml/lml/types/text_type.rb

Overview

LML definition body text. The grammar allows literal braces to be escaped ({ }) so they do not close the definition block; casting unescapes them and normalizes line indentation. One implementation shared by every attribute declared with this type — no per-model (de)serialization procs.

Class Method Summary collapse

Class Method Details

.cast(value, options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lutaml/lml/types/text_type.rb', line 14

def self.cast(value, options = {})
  text = super
  return nil if text.nil?
  return text if Lutaml::Model::Utils.uninitialized?(text)

  text.gsub(/\\}/, '}')
      .gsub(/\\{/, '{')
      .split("\n")
      .map(&:strip)
      .join("\n")
end