class Neo4j::ActiveNode::Query::QueryProxy::Link

Attributes

clause[R]

Public Class Methods

converted_value(model, key, value) click to toggle source
    # File lib/neo4j/active_node/query/query_proxy_link.rb
109 def converted_value(model, key, value)
110   model.declared_properties.value_for_where(key, value)
111 end
for_arg(model, clause, arg, *args) click to toggle source
    # File lib/neo4j/active_node/query/query_proxy_link.rb
101 def for_arg(model, clause, arg, *args)
102   default = [Link.new(clause, arg, *args)]
103 
104   Link.for_clause(clause, arg, model, *args) || default
105 rescue NoMethodError
106   default
107 end
for_args(model, clause, args, association = nil) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
91 def for_args(model, clause, args, association = nil)
92   if [:where, :where_not].include?(clause) && args[0].is_a?(String) # Better way?
93     [for_arg(model, clause, args[0], *args[1..-1])]
94   elsif clause == :rel_where
95     args.map { |arg| for_arg(model, clause, arg, association) }
96   else
97     args.map { |arg| for_arg(model, clause, arg) }
98   end
99 end
for_association(name, value, n_string, model) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
64 def for_association(name, value, n_string, model)
65   neo_id = value.try(:neo_id) || value
66   fail ArgumentError, "Invalid value for '#{name}' condition" if not neo_id.is_a?(Integer)
67 
68   [
69     new(:match, ->(v, _) { "(#{v})#{model.associations[name].arrow_cypher}(#{n_string})" }),
70     new(:where, ->(_, _) { {"ID(#{n_string})" => neo_id.to_i} })
71   ]
72 end
for_clause(clause, arg, model, *args) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
19 def for_clause(clause, arg, model, *args)
20   method_to_call = "for_#{clause}_clause"
21 
22   send(method_to_call, arg, model, *args)
23 end
for_node_where_clause(arg, model, *args)
Alias for: for_where_clause
for_order_clause(arg, _) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
87 def for_order_clause(arg, _)
88   [new(:order, ->(v, _) { arg.is_a?(String) ? arg : {v => arg} })]
89 end
for_rel_order_clause(arg, _) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
83 def for_rel_order_clause(arg, _)
84   [new(:order, ->(_, v) { arg.is_a?(String) ? arg : {v => arg} })]
85 end
for_rel_where_clause(arg, _, association) click to toggle source

We don’t accept strings here. If you want to use a string, just use where.

   # File lib/neo4j/active_node/query/query_proxy_link.rb
75 def for_rel_where_clause(arg, _, association)
76   arg.each_with_object([]) do |(key, value), result|
77     rel_class = association.relationship_class if association.relationship_class
78     val =  rel_class ? converted_value(rel_class, key, value) : value
79     result << new(:where, ->(_, rel_var) { {rel_var => {key => val}} })
80   end
81 end
for_where_clause(arg, model, *args) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
25 def for_where_clause(arg, model, *args)
26   node_num = 1
27   result = []
28   if arg.is_a?(Hash)
29     arg.each do |key, value|
30       if model && model.association?(key)
31         result += for_association(key, value, "n#{node_num}", model)
32         node_num += 1
33       else
34         result << new_for_key_and_value(model, key, value)
35       end
36     end
37   elsif arg.is_a?(String)
38     result << new(:where, arg, args)
39   end
40   result
41 end
Also aliased as: for_node_where_clause
for_where_not_clause(*args) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
44 def for_where_not_clause(*args)
45   for_where_clause(*args).each do |link|
46     link.instance_variable_set('@clause', :where_not)
47   end
48 end
new(clause, arg, args = []) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
 8 def initialize(clause, arg, args = [])
 9   @clause = clause
10   @arg = arg
11   @args = args
12 end
new_for_key_and_value(model, key, value) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
50 def new_for_key_and_value(model, key, value)
51   key = (key.to_sym == :id ? model.id_property_name : key)
52 
53   val = if !model
54           value
55         elsif key == model.id_property_name && value.is_a?(Neo4j::ActiveNode)
56           value.id
57         else
58           converted_value(model, key, value)
59         end
60 
61   new(:where, ->(v, _) { {v => {key => val}} })
62 end

Public Instance Methods

args(var, rel_var) click to toggle source
   # File lib/neo4j/active_node/query/query_proxy_link.rb
14 def args(var, rel_var)
15   @arg.respond_to?(:call) ? @arg.call(var, rel_var) : [@arg, @args].flatten
16 end