Sha256: 421f569e05c15a0580adc885cfd5a9c7d4b763d19ed86932691cc75d1b8d4bcb

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

module Axiom
  module Adapter
    module Arango
      class Visitor
        # Visitor for creating projected documents from axiom header
        class Header < self

          handle(Relation::Header)

          # Return document node
          #
          # @return [AQL::Node]
          #
          # @api private
          #
          def root
            Node::Literal::Composed::Document.new(document_attributes)
          end
          memoize :root

          # Return document attributes
          #
          # @return [Enumerable<AQL::Node>]
          #
          # @api private
          #
          def document_attributes
            input.map do |attribute|
              document_attribute(attribute)
            end
          end
          memoize :document_attributes

        private

          # Return document attribute node
          #
          # @return [Axiom::Attribute] attribute
          #
          # @return [AQL::Node]
          #
          # @api private
          #
          def document_attribute(attribute)
            Node::Literal::Composed::Document::Attribute.new(
              Node::Literal::Primitive::String.new(attribute.name.to_s),
              visit(attribute, context)
            )
          end

        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axiom-arango-adapter-0.0.2 lib/axiom/adapter/arango/visitor/header.rb
axiom-arango-adapter-0.0.1 lib/axiom/adapter/arango/visitor/header.rb