Sha256: 2492e1b9019b3d5723d376c35572e1a81294df0600a4ad6e6986085f8f1c57f6

Contents?: true

Size: 648 Bytes

Versions: 1

Compression:

Stored size: 648 Bytes

Contents

require "jmespath"

module Lutaml
  module LutamlPath
    class DocumentWrapper
      attr_reader :serialized_document

      def initialize(document)
        @serialized_document = serialize_document(document)
      end

      # Method for traversing document` structure
      # example for lutaml: wrapper.find('//#main-doc/main-class/nested-class')
      # Need to return descendant of Lutaml::LutamlPath::EntryWrapper
      def find(path)
        JMESPath.search(path, serialized_document)
      end

      protected

      def serialize_document(_path)
        raise ArgumentError, "implement #serialize_document!"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lutaml-0.2.0 lib/lutaml/lutaml_path/document_wrapper.rb