Sha256: b4dfc1d415cd9d8bc3bc25da0a13c2f15cf7a1e95fe22aba00fec1de1c16e683

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

module ActiveGraph
  module Core
    module QueryExt
      # Creates a ActiveGraph::Node::Query::QueryProxy object that builds off of a Core::Query object.
      #
      # @param [Class] model An Node model to be used as the start of a new QueryuProxy chain
      # @param [Symbol] var The variable to be used to refer to the object from within the new QueryProxy
      # @param [Boolean] optional Indicate whether the new QueryProxy will use MATCH or OPTIONAL MATCH.
      # @return [ActiveGraph::Node::Query::QueryProxy] A QueryProxy object.
      def proxy_as(model, var, optional = false)
        # TODO: Discuss whether it's necessary to call `break` on the query or if this should be left to the user.
        ActiveGraph::Node::Query::QueryProxy.new(model, nil, node: var, optional: optional, starting_query: self, chain_level: @proxy_chain_level)
      end

      # Calls proxy_as with `optional` set true. This doesn't offer anything different from calling `proxy_as` directly but it may be more readable.
      def proxy_as_optional(model, var)
        proxy_as(model, var, true)
      end

      # For instances where you turn a QueryProxy into a Query and then back to a QueryProxy with `#proxy_as`
      attr_accessor :proxy_chain_level
    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/query_ext.rb
activegraph-11.5.0.beta.3 lib/active_graph/core/query_ext.rb
activegraph-12.0.0.beta.3 lib/active_graph/core/query_ext.rb
activegraph-12.0.0.beta.2 lib/active_graph/core/query_ext.rb
activegraph-11.5.0.beta.2 lib/active_graph/core/query_ext.rb
activegraph-12.0.0.beta.1 lib/active_graph/core/query_ext.rb
activegraph-11.5.0.beta.1 lib/active_graph/core/query_ext.rb
activegraph-11.5.0.alpha.1 lib/active_graph/core/query_ext.rb