activegraph 10.0.0.pre.alpha.11 → 10.0.0.pre.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/{neo4j.gemspec → activegraph.gemspec} +7 -9
  4. data/config/neo4j/config.yml +4 -4
  5. data/lib/active_graph.rb +120 -0
  6. data/lib/{neo4j → active_graph}/ansi.rb +1 -1
  7. data/lib/{neo4j → active_graph}/attribute_set.rb +3 -3
  8. data/lib/{neo4j/active_base.rb → active_graph/base.rb} +18 -12
  9. data/lib/{neo4j → active_graph}/class_arguments.rb +5 -5
  10. data/lib/{neo4j → active_graph}/config.rb +10 -10
  11. data/lib/active_graph/core.rb +14 -0
  12. data/lib/{neo4j → active_graph}/core/connection_failed_error.rb +1 -1
  13. data/lib/{neo4j → active_graph}/core/cypher_error.rb +1 -1
  14. data/lib/{neo4j → active_graph}/core/driver.rb +5 -5
  15. data/lib/{neo4j → active_graph}/core/has_uri.rb +1 -1
  16. data/lib/{neo4j → active_graph}/core/instrumentable.rb +4 -4
  17. data/lib/{neo4j → active_graph}/core/label.rb +13 -13
  18. data/lib/{neo4j → active_graph}/core/logging.rb +2 -2
  19. data/lib/{neo4j → active_graph}/core/node.rb +2 -2
  20. data/lib/{neo4j → active_graph}/core/querable.rb +7 -7
  21. data/lib/{neo4j → active_graph}/core/query.rb +16 -16
  22. data/lib/{neo4j → active_graph}/core/query_builder.rb +3 -3
  23. data/lib/{neo4j → active_graph}/core/query_clauses.rb +1 -1
  24. data/lib/{neo4j → active_graph}/core/query_ext.rb +5 -5
  25. data/lib/{neo4j → active_graph}/core/query_find_in_batches.rb +2 -2
  26. data/lib/{neo4j → active_graph}/core/relationship.rb +2 -2
  27. data/lib/{neo4j → active_graph}/core/responses.rb +3 -3
  28. data/lib/{neo4j → active_graph}/core/result.rb +1 -1
  29. data/lib/{neo4j → active_graph}/core/schema.rb +1 -1
  30. data/lib/{neo4j → active_graph}/core/schema_errors.rb +1 -1
  31. data/lib/{neo4j → active_graph}/core/wrappable.rb +1 -1
  32. data/lib/{neo4j → active_graph}/errors.rb +1 -1
  33. data/lib/{neo4j → active_graph}/lazy_attribute_hash.rb +1 -1
  34. data/lib/{neo4j → active_graph}/migration.rb +11 -11
  35. data/lib/{neo4j → active_graph}/migrations.rb +5 -5
  36. data/lib/{neo4j → active_graph}/migrations/base.rb +7 -7
  37. data/lib/{neo4j → active_graph}/migrations/check_pending.rb +3 -3
  38. data/lib/{neo4j → active_graph}/migrations/helpers.rb +4 -4
  39. data/lib/{neo4j → active_graph}/migrations/helpers/id_property.rb +3 -3
  40. data/lib/{neo4j → active_graph}/migrations/helpers/relationships.rb +1 -1
  41. data/lib/{neo4j → active_graph}/migrations/helpers/schema.rb +7 -7
  42. data/lib/{neo4j → active_graph}/migrations/migration_file.rb +1 -1
  43. data/lib/{neo4j → active_graph}/migrations/runner.rb +3 -3
  44. data/lib/{neo4j → active_graph}/migrations/schema.rb +1 -1
  45. data/lib/{neo4j → active_graph}/migrations/schema_migration.rb +2 -2
  46. data/lib/{neo4j → active_graph}/model_schema.rb +8 -8
  47. data/lib/{neo4j/active_node.rb → active_graph/node.rb} +32 -32
  48. data/lib/{neo4j/active_node → active_graph/node}/callbacks.rb +3 -3
  49. data/lib/{neo4j/active_node → active_graph/node}/dependent.rb +2 -2
  50. data/lib/{neo4j/active_node → active_graph/node}/dependent/association_methods.rb +2 -2
  51. data/lib/{neo4j/active_node → active_graph/node}/dependent/query_proxy_methods.rb +4 -4
  52. data/lib/{neo4j/active_node → active_graph/node}/dependent_callbacks.rb +4 -4
  53. data/lib/{neo4j/active_node → active_graph/node}/enum.rb +3 -3
  54. data/lib/{neo4j/active_node → active_graph/node}/has_n.rb +20 -20
  55. data/lib/{neo4j/active_node → active_graph/node}/has_n/association.rb +8 -8
  56. data/lib/{neo4j/active_node → active_graph/node}/has_n/association/rel_factory.rb +4 -4
  57. data/lib/{neo4j/active_node → active_graph/node}/has_n/association/rel_wrapper.rb +4 -4
  58. data/lib/{neo4j/active_node → active_graph/node}/has_n/association_cypher_methods.rb +2 -2
  59. data/lib/{neo4j/active_node → active_graph/node}/id_property.rb +7 -7
  60. data/lib/{neo4j/active_node → active_graph/node}/id_property/accessor.rb +1 -1
  61. data/lib/{neo4j/active_node → active_graph/node}/initialize.rb +3 -3
  62. data/lib/{neo4j/active_node → active_graph/node}/labels.rb +18 -18
  63. data/lib/{neo4j/active_node → active_graph/node}/labels/index.rb +6 -6
  64. data/lib/{neo4j/active_node → active_graph/node}/labels/reloading.rb +1 -1
  65. data/lib/{neo4j/active_node → active_graph/node}/node_list_formatter.rb +1 -1
  66. data/lib/{neo4j/active_node → active_graph/node}/node_wrapper.rb +5 -5
  67. data/lib/{neo4j/active_node → active_graph/node}/orm_adapter.rb +2 -2
  68. data/lib/{neo4j/active_node → active_graph/node}/persistence.rb +7 -7
  69. data/lib/{neo4j/active_node → active_graph/node}/property.rb +3 -3
  70. data/lib/{neo4j/active_node → active_graph/node}/query.rb +9 -9
  71. data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy.rb +19 -19
  72. data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_eager_loading.rb +3 -3
  73. data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_eager_loading/association_tree.rb +2 -2
  74. data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_enumerable.rb +4 -4
  75. data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_find_in_batches.rb +2 -2
  76. data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_link.rb +3 -3
  77. data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_methods.rb +12 -12
  78. data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_methods_of_mass_updating.rb +4 -4
  79. data/lib/{neo4j/active_node → active_graph/node}/query_methods.rb +4 -4
  80. data/lib/{neo4j/active_node → active_graph/node}/reflection.rb +3 -3
  81. data/lib/{neo4j/active_node → active_graph/node}/rels.rb +1 -1
  82. data/lib/{neo4j/active_node → active_graph/node}/scope.rb +4 -4
  83. data/lib/{neo4j/active_node → active_graph/node}/unpersisted.rb +2 -2
  84. data/lib/{neo4j/active_node → active_graph/node}/validations.rb +3 -3
  85. data/lib/{neo4j → active_graph}/paginated.rb +1 -1
  86. data/lib/{neo4j → active_graph}/railtie.rb +18 -18
  87. data/lib/{neo4j/active_rel.rb → active_graph/relationship.rb} +19 -19
  88. data/lib/active_graph/relationship/callbacks.rb +21 -0
  89. data/lib/{neo4j/active_rel → active_graph/relationship}/initialize.rb +5 -5
  90. data/lib/{neo4j/active_rel → active_graph/relationship}/persistence.rb +6 -6
  91. data/lib/{neo4j/active_rel → active_graph/relationship}/persistence/query_factory.rb +7 -7
  92. data/lib/{neo4j/active_rel → active_graph/relationship}/property.rb +6 -6
  93. data/lib/{neo4j/active_rel → active_graph/relationship}/query.rb +7 -7
  94. data/lib/{neo4j/active_rel → active_graph/relationship}/rel_wrapper.rb +5 -5
  95. data/lib/{neo4j/active_rel → active_graph/relationship}/related_node.rb +7 -7
  96. data/lib/{neo4j/active_rel → active_graph/relationship}/types.rb +6 -6
  97. data/lib/active_graph/relationship/validations.rb +8 -0
  98. data/lib/{neo4j → active_graph}/schema/operation.rb +5 -5
  99. data/lib/{neo4j → active_graph}/shared.rb +7 -7
  100. data/lib/{neo4j → active_graph}/shared/attributes.rb +10 -10
  101. data/lib/{neo4j → active_graph}/shared/callbacks.rb +3 -3
  102. data/lib/{neo4j → active_graph}/shared/cypher.rb +1 -1
  103. data/lib/{neo4j → active_graph}/shared/declared_properties.rb +8 -8
  104. data/lib/{neo4j → active_graph}/shared/declared_property.rb +9 -9
  105. data/lib/{neo4j → active_graph}/shared/declared_property/index.rb +3 -3
  106. data/lib/{neo4j → active_graph}/shared/enum.rb +6 -6
  107. data/lib/{neo4j → active_graph}/shared/filtered_hash.rb +2 -2
  108. data/lib/{neo4j → active_graph}/shared/identity.rb +2 -2
  109. data/lib/{neo4j → active_graph}/shared/initialize.rb +3 -3
  110. data/lib/{neo4j → active_graph}/shared/marshal.rb +1 -1
  111. data/lib/{neo4j → active_graph}/shared/mass_assignment.rb +2 -2
  112. data/lib/{neo4j → active_graph}/shared/permitted_attributes.rb +1 -1
  113. data/lib/{neo4j → active_graph}/shared/persistence.rb +4 -4
  114. data/lib/{neo4j → active_graph}/shared/property.rb +10 -10
  115. data/lib/{neo4j → active_graph}/shared/query_factory.rb +5 -5
  116. data/lib/{neo4j → active_graph}/shared/rel_type_converters.rb +6 -6
  117. data/lib/{neo4j → active_graph}/shared/serialized_properties.rb +1 -1
  118. data/lib/{neo4j → active_graph}/shared/type_converters.rb +11 -13
  119. data/lib/{neo4j → active_graph}/shared/typecasted_attributes.rb +7 -7
  120. data/lib/{neo4j → active_graph}/shared/typecaster.rb +3 -3
  121. data/lib/{neo4j → active_graph}/shared/validations.rb +1 -1
  122. data/lib/{neo4j → active_graph}/tasks/migration.rake +25 -25
  123. data/lib/{neo4j → active_graph}/timestamps.rb +3 -3
  124. data/lib/{neo4j → active_graph}/timestamps/created.rb +1 -1
  125. data/lib/{neo4j → active_graph}/timestamps/updated.rb +1 -1
  126. data/lib/{neo4j → active_graph}/transaction.rb +9 -9
  127. data/lib/active_graph/transactions.rb +54 -0
  128. data/lib/{neo4j → active_graph}/type_converters.rb +2 -2
  129. data/lib/{neo4j → active_graph}/undeclared_properties.rb +1 -1
  130. data/lib/active_graph/version.rb +3 -0
  131. data/lib/{neo4j → active_graph}/wrapper.rb +1 -1
  132. data/lib/rails/generators/neo4j/migration/migration_generator.rb +4 -4
  133. data/lib/rails/generators/neo4j/migration/templates/migration.erb +2 -2
  134. data/lib/rails/generators/neo4j/model/model_generator.rb +4 -4
  135. data/lib/rails/generators/neo4j/model/templates/migration.erb +1 -1
  136. data/lib/rails/generators/neo4j/model/templates/model.erb +1 -1
  137. data/lib/rails/generators/neo4j/upgrade_v8/templates/migration.erb +1 -1
  138. data/lib/rails/generators/neo4j/upgrade_v8/upgrade_v8_generator.rb +6 -6
  139. data/lib/rails/generators/neo4j_generator.rb +4 -4
  140. metadata +134 -133
  141. data/lib/neo4j.rb +0 -119
  142. data/lib/neo4j/active_rel/callbacks.rb +0 -21
  143. data/lib/neo4j/active_rel/validations.rb +0 -8
  144. data/lib/neo4j/core.rb +0 -14
  145. data/lib/neo4j/version.rb +0 -3
@@ -1,4 +1,4 @@
1
- module Neo4j::ActiveNode::Labels
1
+ module ActiveGraph::Node::Labels
2
2
  module Reloading
3
3
  extend ActiveSupport::Concern
4
4
 
@@ -1,4 +1,4 @@
1
- module Neo4j::ActiveNode
1
+ module ActiveGraph::Node
2
2
  class NodeListFormatter
3
3
  def initialize(list, max_elements = 5)
4
4
  @list = list
@@ -1,8 +1,8 @@
1
1
  require 'active_support/inflector'
2
- require 'neo4j/core/node'
2
+ require 'active_graph/core/node'
3
3
 
4
4
  wrapping_proc = proc do |node|
5
- found_class = Neo4j::NodeWrapping.class_to_wrap(node.labels)
5
+ found_class = ActiveGraph::NodeWrapping.class_to_wrap(node.labels)
6
6
  next node if not found_class
7
7
 
8
8
  found_class.new.tap do |wrapped_node|
@@ -11,7 +11,7 @@ wrapping_proc = proc do |node|
11
11
  end
12
12
  Neo4j::Driver::Types::Node.wrapper_callback(wrapping_proc)
13
13
 
14
- module Neo4j
14
+ module ActiveGraph
15
15
  module NodeWrapping
16
16
  # Only load classes once for performance
17
17
  CONSTANTS_FOR_LABELS_CACHE = {}
@@ -19,7 +19,7 @@ module Neo4j
19
19
  class << self
20
20
  def class_to_wrap(labels)
21
21
  load_classes_from_labels(labels)
22
- Neo4j::ActiveNode::Labels.model_for_labels(labels).tap do |model_class|
22
+ ActiveGraph::Node::Labels.model_for_labels(labels).tap do |model_class|
23
23
  populate_constants_for_labels_cache(model_class, labels)
24
24
  end
25
25
  end
@@ -47,7 +47,7 @@ module Neo4j
47
47
  end
48
48
 
49
49
  def association_model_namespace
50
- Neo4j::Config.association_model_namespace_string
50
+ ActiveGraph::Config.association_model_namespace_string
51
51
  end
52
52
  end
53
53
  end
@@ -1,7 +1,7 @@
1
1
  require 'orm_adapter'
2
2
 
3
- module Neo4j
4
- module ActiveNode
3
+ module ActiveGraph
4
+ module Node
5
5
  module ClassMethods
6
6
  include OrmAdapter::ToAdapter
7
7
  end
@@ -1,4 +1,4 @@
1
- module Neo4j::ActiveNode
1
+ module ActiveGraph::Node
2
2
  module Persistence
3
3
  class RecordInvalidError < RuntimeError
4
4
  attr_reader :record
@@ -11,7 +11,7 @@ module Neo4j::ActiveNode
11
11
 
12
12
  extend ActiveSupport::Concern
13
13
  extend Forwardable
14
- include Neo4j::Shared::Persistence
14
+ include ActiveGraph::Shared::Persistence
15
15
 
16
16
  # Saves the model.
17
17
  #
@@ -41,11 +41,11 @@ module Neo4j::ActiveNode
41
41
  # to #save! Creates a new transaction.
42
42
  #
43
43
  # @raise a RecordInvalidError if there is a problem during save.
44
- # @param (see Neo4j::Rails::Validations#save)
44
+ # @param (see ActiveGraph::Rails::Validations#save)
45
45
  # @return nil
46
46
  # @see #save
47
- # @see Neo4j::Rails::Validations Neo4j::Rails::Validations - for the :validate parameter
48
- # @see Neo4j::Rails::Callbacks Neo4j::Rails::Callbacks - for callbacks
47
+ # @see ActiveGraph::Rails::Validations ActiveGraph::Rails::Validations - for the :validate parameter
48
+ # @see ActiveGraph::Rails::Callbacks ActiveGraph::Rails::Callbacks - for callbacks
49
49
  def save!(*args)
50
50
  save(*args) or fail(RecordInvalidError, self) # rubocop:disable Style/AndOr
51
51
  end
@@ -64,7 +64,7 @@ module Neo4j::ActiveNode
64
64
  # Creates an unwrapped node in the database.
65
65
  # @param [Hash] node_props The type-converted properties to be added to the new node.
66
66
  # @param [Array] labels The labels to use for creating the new node.
67
- # @return [Neo4j::Node] A CypherNode or EmbeddedNode
67
+ # @return [ActiveGraph::Node] A CypherNode or EmbeddedNode
68
68
  def _create_node(node_props, labels = labels_for_create)
69
69
  query = "CREATE (n:`#{Array(labels).join('`:`')}`) SET n = $props RETURN n"
70
70
  neo4j_query(query, {props: node_props}, wrap_level: :core_entity).to_a[0].n
@@ -162,7 +162,7 @@ module Neo4j::ActiveNode
162
162
  end
163
163
 
164
164
  def query_base_for(neo_id, var = :n)
165
- Neo4j::ActiveBase.new_query.match(var).where(var => {neo_id: neo_id})
165
+ ActiveGraph::Base.new_query.match(var).where(var => {neo_id: neo_id})
166
166
  end
167
167
 
168
168
  private
@@ -1,11 +1,11 @@
1
- module Neo4j::ActiveNode
1
+ module ActiveGraph::Node
2
2
  module Property
3
3
  extend ActiveSupport::Concern
4
- include Neo4j::Shared::Property
4
+ include ActiveGraph::Shared::Property
5
5
 
6
6
  def initialize(attributes = nil)
7
7
  super(attributes)
8
- @attributes ||= Neo4j::AttributeSet.new(self.class.attributes_nil_hash, self.class.attributes.keys)
8
+ @attributes ||= ActiveGraph::AttributeSet.new(self.class.attributes_nil_hash, self.class.attributes.keys)
9
9
  end
10
10
 
11
11
  module ClassMethods
@@ -1,6 +1,6 @@
1
- module Neo4j
2
- module ActiveNode
3
- # Helper methods to return Neo4j::Core::Query objects. A query object can be used to successively build a cypher query
1
+ module ActiveGraph
2
+ module Node
3
+ # Helper methods to return ActiveGraph::Core::Query objects. A query object can be used to successively build a cypher query
4
4
  #
5
5
  # person.query_as(:n).match('n-[:friend]-o').return(o: :name) # Return the names of all the person's friends
6
6
  #
@@ -14,7 +14,7 @@ module Neo4j
14
14
  # mike.query_as(:mike).match('mike-[:friend]-friend').return(friend: :name)
15
15
  #
16
16
  # @param node_var [Symbol, String] The variable name to specify in the query
17
- # @return [Neo4j::Core::Query]
17
+ # @return [ActiveGraph::Core::Query]
18
18
  def query_as(node_var)
19
19
  self.class.query_as(node_var, false).where("ID(#{node_var})" => self.neo_id)
20
20
  end
@@ -27,7 +27,7 @@ module Neo4j
27
27
  # student.as(:s).lessons(:l)
28
28
  #
29
29
  # @param [String, Symbol] node_var The identifier to use within the QueryProxy object
30
- # @return [Neo4j::ActiveNode::Query::QueryProxy]
30
+ # @return [ActiveGraph::Node::Query::QueryProxy]
31
31
  def as(node_var)
32
32
  self.class.query_proxy(node: node_var, source_object: self).match_to(self)
33
33
  end
@@ -42,19 +42,19 @@ module Neo4j
42
42
  # @param [Symbol, String] var The variable name to specify in the query
43
43
  # @param [Boolean] with_labels Should labels be used to build the match? There are situations (neo_id used to filter,
44
44
  # an early Cypher match has already filtered results) where including labels will degrade performance.
45
- # @return [Neo4j::Core::Query]
45
+ # @return [ActiveGraph::Core::Query]
46
46
  def query_as(var, with_labels = true)
47
47
  query_proxy.query_as(var, with_labels)
48
48
  end
49
49
 
50
- Neo4j::ActiveNode::Query::QueryProxy::METHODS.each do |method|
50
+ ActiveGraph::Node::Query::QueryProxy::METHODS.each do |method|
51
51
  define_method(method) do |*args|
52
52
  self.query_proxy.send(method, *args)
53
53
  end
54
54
  end
55
55
 
56
56
  def query_proxy(options = {})
57
- Neo4j::ActiveNode::Query::QueryProxy.new(self, nil, options)
57
+ ActiveGraph::Node::Query::QueryProxy.new(self, nil, options)
58
58
  end
59
59
 
60
60
  # Start a new QueryProxy with the starting identifier set to the given argument.
@@ -66,7 +66,7 @@ module Neo4j
66
66
  # Student.as(:s).lessons
67
67
  #
68
68
  # @param [String, Symbol] node_var A string or symbol to use as the starting identifier.
69
- # @return [Neo4j::ActiveNode::Query::QueryProxy]
69
+ # @return [ActiveGraph::Node::Query::QueryProxy]
70
70
  def as(node_var)
71
71
  query_proxy(node: node_var, context: self.name)
72
72
  end
@@ -1,32 +1,32 @@
1
- module Neo4j
2
- module ActiveNode
1
+ module ActiveGraph
2
+ module Node
3
3
  module Query
4
4
  # rubocop:disable Metrics/ClassLength
5
5
  class QueryProxy
6
6
  # rubocop:enable Metrics/ClassLength
7
- include Neo4j::ActiveNode::Query::QueryProxyEnumerable
8
- include Neo4j::ActiveNode::Query::QueryProxyMethods
9
- include Neo4j::ActiveNode::Query::QueryProxyMethodsOfMassUpdating
10
- include Neo4j::ActiveNode::Query::QueryProxyFindInBatches
11
- include Neo4j::ActiveNode::Query::QueryProxyEagerLoading
12
- include Neo4j::ActiveNode::Dependent::QueryProxyMethods
7
+ include ActiveGraph::Node::Query::QueryProxyEnumerable
8
+ include ActiveGraph::Node::Query::QueryProxyMethods
9
+ include ActiveGraph::Node::Query::QueryProxyMethodsOfMassUpdating
10
+ include ActiveGraph::Node::Query::QueryProxyFindInBatches
11
+ include ActiveGraph::Node::Query::QueryProxyEagerLoading
12
+ include ActiveGraph::Node::Dependent::QueryProxyMethods
13
13
 
14
14
  # The most recent node to start a QueryProxy chain.
15
15
  # Will be nil when using QueryProxy chains on class methods.
16
16
  attr_reader :source_object, :association, :model, :starting_query
17
17
 
18
- # QueryProxy is ActiveNode's Cypher DSL. While the name might imply that it creates queries in a general sense,
19
- # it is actually referring to <tt>Neo4j::Core::Query</tt>, which is a pure Ruby Cypher DSL provided by the <tt>neo4j-core</tt> gem.
18
+ # QueryProxy is Node's Cypher DSL. While the name might imply that it creates queries in a general sense,
19
+ # it is actually referring to <tt>ActiveGraph::Core::Query</tt>, which is a pure Ruby Cypher DSL provided by the <tt>neo4j-core</tt> gem.
20
20
  # QueryProxy provides ActiveRecord-like methods for common patterns. When it's not handling CRUD for relationships and queries, it
21
- # provides ActiveNode's association chaining (`student.lessons.teachers.where(age: 30).hobbies`) and enjoys long walks on the
21
+ # provides Node's association chaining (`student.lessons.teachers.where(age: 30).hobbies`) and enjoys long walks on the
22
22
  # beach.
23
23
  #
24
24
  # It should not ever be necessary to instantiate a new QueryProxy object directly, it always happens as a result of
25
25
  # calling a method that makes use of it.
26
26
  #
27
- # @param [Constant] model The class which included ActiveNode (typically a model, hence the name) from which the query
27
+ # @param [Constant] model The class which included Node (typically a model, hence the name) from which the query
28
28
  # originated.
29
- # @param [Neo4j::ActiveNode::HasN::Association] association The ActiveNode association (an object created by a <tt>has_one</tt> or
29
+ # @param [ActiveGraph::Node::HasN::Association] association The Node association (an object created by a <tt>has_one</tt> or
30
30
  # <tt>has_many</tt>) that created this object.
31
31
  # @param [Hash] options Additional options pertaining to the QueryProxy object. These may include:
32
32
  # @option options [String, Symbol] :node_var A string or symbol to be used by Cypher within its query string as an identifier
@@ -34,7 +34,7 @@ module Neo4j
34
34
  # @option options [Range, Integer, Symbol, Hash] :rel_length A Range, a Integer, a Hash or a Symbol to indicate the variable-length/fixed-length
35
35
  # qualifier of the relationship. See http://neo4jrb.readthedocs.org/en/latest/Querying.html#variable-length-relationships.
36
36
  # @option options [Neo4j::Driver] :driver The driver to be used for this query
37
- # @option options [Neo4j::ActiveNode] :source_object The node instance at the start of the QueryProxy chain
37
+ # @option options [ActiveGraph::Node] :source_object The node instance at the start of the QueryProxy chain
38
38
  # @option options [QueryProxy] :query_proxy An existing QueryProxy chain upon which this new object should be built
39
39
  #
40
40
  # QueryProxy objects are evaluated lazily.
@@ -56,7 +56,7 @@ module Neo4j
56
56
  end
57
57
 
58
58
  def inspect
59
- formatted_nodes = Neo4j::ActiveNode::NodeListFormatter.new(to_a)
59
+ formatted_nodes = ActiveGraph::Node::NodeListFormatter.new(to_a)
60
60
  "#<QueryProxy #{@context} #{formatted_nodes.inspect}>"
61
61
  end
62
62
 
@@ -87,8 +87,8 @@ module Neo4j
87
87
  query_as(identity)
88
88
  end
89
89
 
90
- # Build a Neo4j::Core::Query object for the QueryProxy. This is necessary when you want to take an existing QueryProxy chain
91
- # and work with it from the more powerful (but less friendly) Neo4j::Core::Query.
90
+ # Build a ActiveGraph::Core::Query object for the QueryProxy. This is necessary when you want to take an existing QueryProxy chain
91
+ # and work with it from the more powerful (but less friendly) ActiveGraph::Core::Query.
92
92
  # @param [String,Symbol] var The identifier to use for node at this link of the QueryProxy chain.
93
93
  #
94
94
  # .. code-block:: ruby
@@ -205,7 +205,7 @@ module Neo4j
205
205
  fail 'Can only create relationships on associations' if !@association
206
206
  other_nodes = _nodeify!(*other_nodes)
207
207
 
208
- Neo4j::ActiveBase.run_transaction do
208
+ ActiveGraph::Base.run_transaction do
209
209
  other_nodes.each do |other_node|
210
210
  if other_node.neo_id
211
211
  other_node.try(:delete_reverse_has_one_core_rel, association)
@@ -310,7 +310,7 @@ module Neo4j
310
310
  end
311
311
 
312
312
  def _query
313
- Neo4j::ActiveBase.new_query(context: @context)
313
+ ActiveGraph::Base.new_query(context: @context)
314
314
  end
315
315
 
316
316
  def _result_string(index = nil)
@@ -1,5 +1,5 @@
1
- module Neo4j
2
- module ActiveNode
1
+ module ActiveGraph
2
+ module Node
3
3
  module Query
4
4
  module QueryProxyEagerLoading
5
5
  class IdentityMap < Hash
@@ -59,7 +59,7 @@ module Neo4j
59
59
  def add_to_cache(rel, node, element)
60
60
  direction = element.association.direction
61
61
  node = cache_and_init(node, element)
62
- if rel.is_a?(Neo4j::ActiveRel)
62
+ if rel.is_a?(ActiveGraph::Relationship)
63
63
  rel.instance_variable_set(direction == :in ? '@from_node' : '@to_node', node)
64
64
  end
65
65
  @_cache[direction == :out ? rel.start_node_neo_id : rel.end_node_neo_id]
@@ -1,5 +1,5 @@
1
- module Neo4j
2
- module ActiveNode
1
+ module ActiveGraph
2
+ module Node
3
3
  module Query
4
4
  module QueryProxyEagerLoading
5
5
  class AssociationTree < Hash
@@ -1,5 +1,5 @@
1
- module Neo4j
2
- module ActiveNode
1
+ module ActiveGraph
2
+ module Node
3
3
  module Query
4
4
  # Methods related to returning nodes and rels from QueryProxy
5
5
  module QueryProxyEnumerable
@@ -69,7 +69,7 @@ module Neo4j
69
69
  def pluck(*args)
70
70
  transformable_attributes = (model ? model.attribute_names : []) + %w(uuid neo_id)
71
71
  arg_list = args.map do |arg|
72
- arg = Neo4j::ActiveNode::Query::QueryProxy::Link.converted_key(model, arg)
72
+ arg = ActiveGraph::Node::Query::QueryProxy::Link.converted_key(model, arg)
73
73
  if transformable_attributes.include?(arg.to_s)
74
74
  {identity => arg}
75
75
  else
@@ -99,7 +99,7 @@ module Neo4j
99
99
  instance.each do |object|
100
100
  object.instance_variable_set('@source_query_proxy', self)
101
101
  object.instance_variable_set('@source_proxy_result_cache', instance)
102
- if node && rel && object.last.is_a?(Neo4j::ActiveRel)
102
+ if node && rel && object.last.is_a?(ActiveGraph::Relationship)
103
103
  object.last.instance_variable_set(association.direction == :in ? '@from_node' : '@to_node', object.first)
104
104
  end
105
105
  end
@@ -1,5 +1,5 @@
1
- module Neo4j
2
- module ActiveNode
1
+ module ActiveGraph
2
+ module Node
3
3
  module Query
4
4
  module QueryProxyFindInBatches
5
5
  def find_in_batches(options = {})
@@ -1,5 +1,5 @@
1
- module Neo4j
2
- module ActiveNode
1
+ module ActiveGraph
2
+ module Node
3
3
  module Query
4
4
  class QueryProxy
5
5
  class Link
@@ -56,7 +56,7 @@ module Neo4j
56
56
 
57
57
  val = if !model
58
58
  value
59
- elsif key == model.id_property_name && value.is_a?(Neo4j::ActiveNode)
59
+ elsif key == model.id_property_name && value.is_a?(ActiveGraph::Node)
60
60
  value.id
61
61
  else
62
62
  converted_value(model, key, value)
@@ -1,5 +1,5 @@
1
- module Neo4j
2
- module ActiveNode
1
+ module ActiveGraph
2
+ module Node
3
3
  module Query
4
4
  # rubocop:disable Metrics/ModuleLength
5
5
  module QueryProxyMethods
@@ -54,7 +54,7 @@ module Neo4j
54
54
  # @return [Integer] number of nodes of this class
55
55
  def count(distinct = nil, target = nil)
56
56
  return 0 if unpersisted_start_object?
57
- fail(Neo4j::InvalidParameterError, ':count accepts the `:distinct` symbol or nil as a parameter') unless distinct.nil? || distinct == :distinct
57
+ fail(ActiveGraph::InvalidParameterError, ':count accepts the `:distinct` symbol or nil as a parameter') unless distinct.nil? || distinct == :distinct
58
58
  query_with_target(target) do |var|
59
59
  q = ensure_distinct(var, !distinct.nil?)
60
60
  limited_query = self.query.clause?(:limit) ? self.query.break.with(var) : self.query.reorder
@@ -71,7 +71,7 @@ module Neo4j
71
71
  # TODO: update this with public API methods if/when they are exposed
72
72
  def limit_value
73
73
  return unless self.query.clause?(:limit)
74
- limit_clause = self.query.send(:clauses).find { |clause| clause.is_a?(Neo4j::Core::QueryClauses::LimitClause) }
74
+ limit_clause = self.query.send(:clauses).find { |clause| clause.is_a?(ActiveGraph::Core::QueryClauses::LimitClause) }
75
75
  limit_clause.instance_variable_get(:@arg)
76
76
  end
77
77
 
@@ -82,7 +82,7 @@ module Neo4j
82
82
 
83
83
  alias blank? empty?
84
84
 
85
- # @param [Neo4j::ActiveNode, Neo4j::Node, String] other An instance of a Neo4j.rb model, a Neo4j-core node, or a string uuid
85
+ # @param [ActiveGraph::Node, ActiveGraph::Node, String] other An instance of a Neo4j.rb model, a Neo4j-core node, or a string uuid
86
86
  # @param [String, Symbol] target An identifier of a link in the Cypher chain
87
87
  # @return [Boolean]
88
88
  def include?(other, target = nil)
@@ -99,7 +99,7 @@ module Neo4j
99
99
 
100
100
  def exists?(node_condition = nil, target = nil)
101
101
  unless [Integer, String, Hash, NilClass].any? { |c| node_condition.is_a?(c) }
102
- fail(Neo4j::InvalidParameterError, ':exists? only accepts ids or conditions')
102
+ fail(ActiveGraph::InvalidParameterError, ':exists? only accepts ids or conditions')
103
103
  end
104
104
  query_with_target(target) do |var|
105
105
  start_q = exists_query_start(node_condition, var)
@@ -109,12 +109,12 @@ module Neo4j
109
109
  end
110
110
 
111
111
  # Shorthand for `MATCH (start)-[r]-(other_node) WHERE ID(other_node) = #{other_node.neo_id}`
112
- # The `node` param can be a persisted ActiveNode instance, any string or integer, or nil.
112
+ # The `node` param can be a persisted Node instance, any string or integer, or nil.
113
113
  # When it's a node, it'll use the object's neo_id, which is fastest. When not nil, it'll figure out the
114
114
  # primary key of that model. When nil, it uses `1 = 2` to prevent matching all records, which is the default
115
115
  # behavior when nil is passed to `where` in QueryProxy.
116
116
  # @param [#neo_id, String, Enumerable] node A node, a string representing a node's ID, or an enumerable of nodes or IDs.
117
- # @return [Neo4j::ActiveNode::Query::QueryProxy] A QueryProxy object upon which you can build.
117
+ # @return [ActiveGraph::Node::Query::QueryProxy] A QueryProxy object upon which you can build.
118
118
  def match_to(node)
119
119
  first_node = node.is_a?(Array) ? node.first : node
120
120
  where_arg = if first_node.respond_to?(:neo_id)
@@ -133,7 +133,7 @@ module Neo4j
133
133
  # Gives you the first relationship between the last link of a QueryProxy chain and a given node
134
134
  # Shorthand for `MATCH (start)-[r]-(other_node) WHERE ID(other_node) = #{other_node.neo_id} RETURN r`
135
135
  # @param [#neo_id, String, Enumerable] node An object to be sent to `match_to`. See params for that method.
136
- # @return A relationship (ActiveRel, CypherRelationship, EmbeddedRelationship) or nil.
136
+ # @return A relationship (Relationship, CypherRelationship, EmbeddedRelationship) or nil.
137
137
  def first_rel_to(node)
138
138
  self.match_to(node).limit(1).pluck(rel_var).first
139
139
  end
@@ -152,7 +152,7 @@ module Neo4j
152
152
  fail 'Method invalid when called on Class objects' unless source_object
153
153
  result = self.where(params).first
154
154
  return result unless result.nil?
155
- Neo4j::ActiveBase.run_transaction do
155
+ ActiveGraph::Base.run_transaction do
156
156
  node = model.create(params)
157
157
  self << node
158
158
  return node
@@ -172,7 +172,7 @@ module Neo4j
172
172
  self.send(association, node_var, rel_var, optional: true)
173
173
  end
174
174
 
175
- # Takes an Array of ActiveNode models and applies the appropriate WHERE clause
175
+ # Takes an Array of Node models and applies the appropriate WHERE clause
176
176
  # So for a `Teacher` model inheriting from a `Person` model and an `Article` model
177
177
  # if you called .as_models([Teacher, Article])
178
178
  # The where clause would look something like:
@@ -250,7 +250,7 @@ module Neo4j
250
250
  end
251
251
 
252
252
  def where_clause_params
253
- query.clauses.select { |c| c.is_a?(Neo4j::Core::QueryClauses::WhereClause) && c.arg.is_a?(Hash) }
253
+ query.clauses.select { |c| c.is_a?(ActiveGraph::Core::QueryClauses::WhereClause) && c.arg.is_a?(Hash) }
254
254
  .map! { |e| e.arg[identity] }.compact.inject { |a, b| a.merge(b) } || {}
255
255
  end
256
256
 
@@ -1,5 +1,5 @@
1
- module Neo4j
2
- module ActiveNode
1
+ module ActiveGraph
2
+ module Node
3
3
  module Query
4
4
  module QueryProxyMethodsOfMassUpdating
5
5
  # Updates some attributes of a group of nodes within a QP chain.
@@ -7,7 +7,7 @@ module Neo4j
7
7
  # @param [Hash,String] updates An hash or a string of parameters to be updated.
8
8
  # @param [Hash] params An hash of parameters for the update string. It's ignored if `updates` is an Hash.
9
9
  def update_all(updates, params = {})
10
- # Move this to ActiveNode module?
10
+ # Move this to Node module?
11
11
  update_all_with_query(identity, updates, params)
12
12
  end
13
13
 
@@ -27,7 +27,7 @@ module Neo4j
27
27
  query_with_target(identifier) do |target|
28
28
  begin
29
29
  self.query.with(target).optional_match("(#{target})-[#{target}_rel]-()").delete("#{target}, #{target}_rel").exec
30
- rescue Neo4j::Core::CypherError # <=- Seems hacky
30
+ rescue ActiveGraph::Core::CypherError # <=- Seems hacky
31
31
  self.query.delete(target).exec
32
32
  end
33
33
  clear_source_object_cache