Sha256: 0cca5ff16f2a8c2c63ad8647a1108688437908e53a6350d3b31e2f41077a27ad

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

require 'active_graph/core/instrumentable'
require 'active_graph/transaction'
require 'active_graph/core/query_builder'
require 'active_graph/core/record'

module ActiveGraph
  module Core
    module Querable
      extend ActiveSupport::Concern
      include Instrumentable

      class_methods do
        def query(*args)
          options = case args.size
                    when 3
                      args.pop
                    when 2
                      args.pop if args[0].is_a?(::ActiveGraph::Core::Query)
                    end || {}

          query_run(QueryBuilder.query(*args), options)
        end

        def setup_query!(query, options = {})
          return if options[:skip_instrumentation]
          ActiveSupport::Notifications.instrument('neo4j.core.cypher_query', query: query)
        end

        def query_run(query, options = {})
          setup_query!(query, skip_instrumentation: options[:skip_instrumentation])

          ActiveSupport::Notifications.instrument('neo4j.core.bolt.request') do
            transaction do |tx|
              tx.run(query.cypher, query.parameters).tap { |result| result.wrap = options[:wrap] != false }
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activegraph-11.0.2-java lib/active_graph/core/querable.rb
activegraph-11.0.1-java lib/active_graph/core/querable.rb
activegraph-11.0.0-java lib/active_graph/core/querable.rb
activegraph-11.0.0.beta.4-java lib/active_graph/core/querable.rb
activegraph-11.0.0.beta.3-java lib/active_graph/core/querable.rb
activegraph-11.0.0.beta.2-java lib/active_graph/core/querable.rb
activegraph-11.0.0.beta.1-java lib/active_graph/core/querable.rb