Sha256: 63b21e136ade45df77bcfc08a26d92a26f3e89c2859cd5f239c02dd8897ac1ef

Contents?: true

Size: 830 Bytes

Versions: 3

Compression:

Stored size: 830 Bytes

Contents

module ActiveGraph
  module Core
    class QueryBuilder
      attr_reader :queries

      Query = Struct.new(:cypher, :parameters, :pretty_cypher, :context)

      def initialize
        @queries = []
      end

      def append(*args)
        query = case args.map(&:class)
                when [String], [String, Hash]
                  Query.new(args[0], args[1] || {})
                when [::ActiveGraph::Core::Query]
                  args[0]
                else
                  fail ArgumentError, "Could not determine query from arguments: #{args.inspect}"
                end

        @queries << query
      end

      def query
        # `nil` drivers are just a workaround until
        # we phase out `Query` objects containing drivers
        ActiveGraph::Core::Query.new(driver: nil)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activegraph-10.0.0.pre.beta.3 lib/active_graph/core/query_builder.rb
activegraph-10.0.0.pre.beta.2 lib/active_graph/core/query_builder.rb
activegraph-10.0.0.pre.beta.1 lib/active_graph/core/query_builder.rb