Sha256: 7a9b5c3f50c6317614ecb9ca38b1474acc5807fc984d612be188abcf0abe6b64
Contents?: true
Size: 840 Bytes
Versions: 5
Compression:
Stored size: 840 Bytes
Contents
require "yaml" require_relative "yaml_document" module Lutaml module Model module YamlAdapter class StandardYamlAdapter < YamlDocument def self.parse(yaml) YAML.safe_load( yaml, permitted_classes: [Date, Time, DateTime, Symbol, BigDecimal, Hash, Array], ) end def to_yaml(options = {}) YAML.dump(@attributes, options) end # TODO: Is this really needed? def self.to_yaml(attributes, *args) new(attributes).to_yaml(*args) end # TODO: Is this really needed? def self.from_yaml(yaml, klass) data = parse(yaml) mapped_attrs = klass.send(:apply_mappings, data, :yaml) klass.new(mapped_attrs) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems