Sha256: 24218d4728e67658dff75d138517ab9d6588d4115e9a87bd2feccb7374481673

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

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

8 entries across 8 versions & 1 rubygems

Version Path
activegraph-12.0.0.beta.4 lib/active_graph/core/querable.rb
activegraph-11.5.0.beta.3 lib/active_graph/core/querable.rb
activegraph-12.0.0.beta.3 lib/active_graph/core/querable.rb
activegraph-12.0.0.beta.2 lib/active_graph/core/querable.rb
activegraph-11.5.0.beta.2 lib/active_graph/core/querable.rb
activegraph-12.0.0.beta.1 lib/active_graph/core/querable.rb
activegraph-11.5.0.beta.1 lib/active_graph/core/querable.rb
activegraph-11.5.0.alpha.1 lib/active_graph/core/querable.rb