Sha256: 9036bcb46edf42635ad3cd67a1807914b07c2fb35d1353768de5d8fd3771b516

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

module Axiom
  module Adapter
    module Arango
      class Visitor
        class For
          class Unary
            # Visitor for emitting extensions
            class Extension < self

              handle(Algebra::Extension)

              LOCAL_NAME = AQL.name_node('extension')

            private

              # Return for body
              #
              # @return [AQL::Node]
              #
              # @api private
              #
              def body
                return_operation
              end

              # Return return value
              #
              # @return [AQL::Node::Call]
              #
              # @api private
              #
              def return_value
                Node::Call.new('MERGE', [local_name, Node::Literal::Composed::Document.new(extended_attributes)])
              end

              # Return document attribute node
              #
              # @return [Axiom::Attribute] attribute
              #
              # @return [AQL::Node]
              #
              # @api private
              #
              def extended_attributes
                input.extensions.map do |attribute, function|
                  document_attribute(attribute, function)
                end
              end

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

            end
          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/for/unary/extension.rb
axiom-arango-adapter-0.0.1 lib/axiom/adapter/arango/visitor/for/unary/extension.rb