class Lutaml::LutamlPath::DocumentWrapper
Attributes
original_document[R]
serialized_document[R]
Public Class Methods
new(document)
click to toggle source
# File lib/lutaml/lutaml_path/document_wrapper.rb, line 6 def initialize(document) @original_document = document @serialized_document = serialize_document(document) end
Public Instance Methods
to_liquid()
click to toggle source
# File lib/lutaml/lutaml_path/document_wrapper.rb, line 11 def to_liquid serialized_document end
Protected Instance Methods
serialize_document(_path)
click to toggle source
# File lib/lutaml/lutaml_path/document_wrapper.rb, line 17 def serialize_document(_path) raise ArgumentError, "implement #serialize_document!" end
serialize_to_hash(object)
click to toggle source
# File lib/lutaml/lutaml_path/document_wrapper.rb, line 29 def serialize_to_hash(object) return object if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass, Hash].include?(object.class) object.instance_variables.each_with_object({}) do |var, res| variable = object.instance_variable_get(var) res[var.to_s.gsub("@", "")] = if variable.is_a?(Array) variable.map do |n| serialize_to_hash(n) end else if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass, Hash].include?(variable.class) || var == :@parent variable else serialize_to_hash(variable) end end end end
serialize_value(attr_value)
click to toggle source
# File lib/lutaml/lutaml_path/document_wrapper.rb, line 21 def serialize_value(attr_value) if attr_value.is_a?(Array) return attr_value.map(&method(:serialize_to_hash)) end serialize_to_hash(attr_value) end