Sha256: 6f2fc4badf69c9c46af274178c62f0210c0a642bb1f5dd600024f7f9d03b5d23

Contents?: true

Size: 738 Bytes

Versions: 4

Compression:

Stored size: 738 Bytes

Contents

# lib/lutaml/model/json_adapter.rb
require "json"

module Lutaml
  module Model
    module JsonAdapter
      class JsonObject
        attr_reader :attributes

        def initialize(attributes = {})
          @attributes = attributes
        end

        def [](key)
          @attributes[key]
        end

        def []=(key, value)
          @attributes[key] = value
        end

        def to_h
          @attributes
        end
      end

      class Document < JsonObject
        def self.parse(json)
          raise NotImplementedError, "Subclasses must implement `parse`."
        end

        def to_json(*args)
          raise NotImplementedError, "Subclasses must implement `to_json`."
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lutaml-model-0.3.1 lib/lutaml/model/json_adapter.rb
lutaml-model-0.3.0 lib/lutaml/model/json_adapter.rb
lutaml-model-0.2.1 lib/lutaml/model/json_adapter.rb
lutaml-model-0.1.0 lib/lutaml/model/json_adapter.rb