Sha256: 21767ba1bc8beb09271324aec995a17b1a4db74ed675798e461e0f731235c811

Contents?: true

Size: 755 Bytes

Versions: 6

Compression:

Stored size: 755 Bytes

Contents

require "yaml"
require_relative "yaml_document"

module Lutaml
  module Model
    module YamlAdapter
      class StandardYamlAdapter < YamlDocument
        PERMITTED_CLASSES_BASE = [Date, Time, DateTime, Symbol, Hash,
                                  Array].freeze

        PERMITTED_CLASSES = if defined?(BigDecimal)
                              PERMITTED_CLASSES_BASE + [BigDecimal]
                            else
                              PERMITTED_CLASSES_BASE
                            end.freeze

        def self.parse(yaml, _options = {})
          YAML.safe_load(yaml, permitted_classes: PERMITTED_CLASSES)
        end

        def to_yaml(options = {})
          YAML.dump(@attributes, options)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lutaml-model-0.5.3 lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb
lutaml-model-0.5.2 lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb
lutaml-model-0.5.1 lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb
lutaml-model-0.5.0 lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb
lutaml-model-0.4.0 lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb
lutaml-model-0.3.30 lib/lutaml/model/yaml_adapter/standard_yaml_adapter.rb