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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/{neo4j.gemspec → activegraph.gemspec} +7 -9
- data/config/neo4j/config.yml +4 -4
- data/lib/active_graph.rb +120 -0
- data/lib/{neo4j → active_graph}/ansi.rb +1 -1
- data/lib/{neo4j → active_graph}/attribute_set.rb +3 -3
- data/lib/{neo4j/active_base.rb → active_graph/base.rb} +18 -12
- data/lib/{neo4j → active_graph}/class_arguments.rb +5 -5
- data/lib/{neo4j → active_graph}/config.rb +10 -10
- data/lib/active_graph/core.rb +14 -0
- data/lib/{neo4j → active_graph}/core/connection_failed_error.rb +1 -1
- data/lib/{neo4j → active_graph}/core/cypher_error.rb +1 -1
- data/lib/{neo4j → active_graph}/core/driver.rb +5 -5
- data/lib/{neo4j → active_graph}/core/has_uri.rb +1 -1
- data/lib/{neo4j → active_graph}/core/instrumentable.rb +4 -4
- data/lib/{neo4j → active_graph}/core/label.rb +13 -13
- data/lib/{neo4j → active_graph}/core/logging.rb +2 -2
- data/lib/{neo4j → active_graph}/core/node.rb +2 -2
- data/lib/{neo4j → active_graph}/core/querable.rb +7 -7
- data/lib/{neo4j → active_graph}/core/query.rb +16 -16
- data/lib/{neo4j → active_graph}/core/query_builder.rb +3 -3
- data/lib/{neo4j → active_graph}/core/query_clauses.rb +1 -1
- data/lib/{neo4j → active_graph}/core/query_ext.rb +5 -5
- data/lib/{neo4j → active_graph}/core/query_find_in_batches.rb +2 -2
- data/lib/{neo4j → active_graph}/core/relationship.rb +2 -2
- data/lib/{neo4j → active_graph}/core/responses.rb +3 -3
- data/lib/{neo4j → active_graph}/core/result.rb +1 -1
- data/lib/{neo4j → active_graph}/core/schema.rb +1 -1
- data/lib/{neo4j → active_graph}/core/schema_errors.rb +1 -1
- data/lib/{neo4j → active_graph}/core/wrappable.rb +1 -1
- data/lib/{neo4j → active_graph}/errors.rb +1 -1
- data/lib/{neo4j → active_graph}/lazy_attribute_hash.rb +1 -1
- data/lib/{neo4j → active_graph}/migration.rb +11 -11
- data/lib/{neo4j → active_graph}/migrations.rb +5 -5
- data/lib/{neo4j → active_graph}/migrations/base.rb +7 -7
- data/lib/{neo4j → active_graph}/migrations/check_pending.rb +3 -3
- data/lib/{neo4j → active_graph}/migrations/helpers.rb +4 -4
- data/lib/{neo4j → active_graph}/migrations/helpers/id_property.rb +3 -3
- data/lib/{neo4j → active_graph}/migrations/helpers/relationships.rb +1 -1
- data/lib/{neo4j → active_graph}/migrations/helpers/schema.rb +7 -7
- data/lib/{neo4j → active_graph}/migrations/migration_file.rb +1 -1
- data/lib/{neo4j → active_graph}/migrations/runner.rb +3 -3
- data/lib/{neo4j → active_graph}/migrations/schema.rb +1 -1
- data/lib/{neo4j → active_graph}/migrations/schema_migration.rb +2 -2
- data/lib/{neo4j → active_graph}/model_schema.rb +8 -8
- data/lib/{neo4j/active_node.rb → active_graph/node.rb} +32 -32
- data/lib/{neo4j/active_node → active_graph/node}/callbacks.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/dependent.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/dependent/association_methods.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/dependent/query_proxy_methods.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/dependent_callbacks.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/enum.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/has_n.rb +20 -20
- data/lib/{neo4j/active_node → active_graph/node}/has_n/association.rb +8 -8
- data/lib/{neo4j/active_node → active_graph/node}/has_n/association/rel_factory.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/has_n/association/rel_wrapper.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/has_n/association_cypher_methods.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/id_property.rb +7 -7
- data/lib/{neo4j/active_node → active_graph/node}/id_property/accessor.rb +1 -1
- data/lib/{neo4j/active_node → active_graph/node}/initialize.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/labels.rb +18 -18
- data/lib/{neo4j/active_node → active_graph/node}/labels/index.rb +6 -6
- data/lib/{neo4j/active_node → active_graph/node}/labels/reloading.rb +1 -1
- data/lib/{neo4j/active_node → active_graph/node}/node_list_formatter.rb +1 -1
- data/lib/{neo4j/active_node → active_graph/node}/node_wrapper.rb +5 -5
- data/lib/{neo4j/active_node → active_graph/node}/orm_adapter.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/persistence.rb +7 -7
- data/lib/{neo4j/active_node → active_graph/node}/property.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/query.rb +9 -9
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy.rb +19 -19
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_eager_loading.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_eager_loading/association_tree.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_enumerable.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_find_in_batches.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_link.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_methods.rb +12 -12
- data/lib/{neo4j/active_node → active_graph/node}/query/query_proxy_methods_of_mass_updating.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/query_methods.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/reflection.rb +3 -3
- data/lib/{neo4j/active_node → active_graph/node}/rels.rb +1 -1
- data/lib/{neo4j/active_node → active_graph/node}/scope.rb +4 -4
- data/lib/{neo4j/active_node → active_graph/node}/unpersisted.rb +2 -2
- data/lib/{neo4j/active_node → active_graph/node}/validations.rb +3 -3
- data/lib/{neo4j → active_graph}/paginated.rb +1 -1
- data/lib/{neo4j → active_graph}/railtie.rb +18 -18
- data/lib/{neo4j/active_rel.rb → active_graph/relationship.rb} +19 -19
- data/lib/active_graph/relationship/callbacks.rb +21 -0
- data/lib/{neo4j/active_rel → active_graph/relationship}/initialize.rb +5 -5
- data/lib/{neo4j/active_rel → active_graph/relationship}/persistence.rb +6 -6
- data/lib/{neo4j/active_rel → active_graph/relationship}/persistence/query_factory.rb +7 -7
- data/lib/{neo4j/active_rel → active_graph/relationship}/property.rb +6 -6
- data/lib/{neo4j/active_rel → active_graph/relationship}/query.rb +7 -7
- data/lib/{neo4j/active_rel → active_graph/relationship}/rel_wrapper.rb +5 -5
- data/lib/{neo4j/active_rel → active_graph/relationship}/related_node.rb +7 -7
- data/lib/{neo4j/active_rel → active_graph/relationship}/types.rb +6 -6
- data/lib/active_graph/relationship/validations.rb +8 -0
- data/lib/{neo4j → active_graph}/schema/operation.rb +5 -5
- data/lib/{neo4j → active_graph}/shared.rb +7 -7
- data/lib/{neo4j → active_graph}/shared/attributes.rb +10 -10
- data/lib/{neo4j → active_graph}/shared/callbacks.rb +3 -3
- data/lib/{neo4j → active_graph}/shared/cypher.rb +1 -1
- data/lib/{neo4j → active_graph}/shared/declared_properties.rb +8 -8
- data/lib/{neo4j → active_graph}/shared/declared_property.rb +9 -9
- data/lib/{neo4j → active_graph}/shared/declared_property/index.rb +3 -3
- data/lib/{neo4j → active_graph}/shared/enum.rb +6 -6
- data/lib/{neo4j → active_graph}/shared/filtered_hash.rb +2 -2
- data/lib/{neo4j → active_graph}/shared/identity.rb +2 -2
- data/lib/{neo4j → active_graph}/shared/initialize.rb +3 -3
- data/lib/{neo4j → active_graph}/shared/marshal.rb +1 -1
- data/lib/{neo4j → active_graph}/shared/mass_assignment.rb +2 -2
- data/lib/{neo4j → active_graph}/shared/permitted_attributes.rb +1 -1
- data/lib/{neo4j → active_graph}/shared/persistence.rb +4 -4
- data/lib/{neo4j → active_graph}/shared/property.rb +10 -10
- data/lib/{neo4j → active_graph}/shared/query_factory.rb +5 -5
- data/lib/{neo4j → active_graph}/shared/rel_type_converters.rb +6 -6
- data/lib/{neo4j → active_graph}/shared/serialized_properties.rb +1 -1
- data/lib/{neo4j → active_graph}/shared/type_converters.rb +11 -13
- data/lib/{neo4j → active_graph}/shared/typecasted_attributes.rb +7 -7
- data/lib/{neo4j → active_graph}/shared/typecaster.rb +3 -3
- data/lib/{neo4j → active_graph}/shared/validations.rb +1 -1
- data/lib/{neo4j → active_graph}/tasks/migration.rake +25 -25
- data/lib/{neo4j → active_graph}/timestamps.rb +3 -3
- data/lib/{neo4j → active_graph}/timestamps/created.rb +1 -1
- data/lib/{neo4j → active_graph}/timestamps/updated.rb +1 -1
- data/lib/{neo4j → active_graph}/transaction.rb +9 -9
- data/lib/active_graph/transactions.rb +54 -0
- data/lib/{neo4j → active_graph}/type_converters.rb +2 -2
- data/lib/{neo4j → active_graph}/undeclared_properties.rb +1 -1
- data/lib/active_graph/version.rb +3 -0
- data/lib/{neo4j → active_graph}/wrapper.rb +1 -1
- data/lib/rails/generators/neo4j/migration/migration_generator.rb +4 -4
- data/lib/rails/generators/neo4j/migration/templates/migration.erb +2 -2
- data/lib/rails/generators/neo4j/model/model_generator.rb +4 -4
- data/lib/rails/generators/neo4j/model/templates/migration.erb +1 -1
- data/lib/rails/generators/neo4j/model/templates/model.erb +1 -1
- data/lib/rails/generators/neo4j/upgrade_v8/templates/migration.erb +1 -1
- data/lib/rails/generators/neo4j/upgrade_v8/upgrade_v8_generator.rb +6 -6
- data/lib/rails/generators/neo4j_generator.rb +4 -4
- metadata +134 -133
- data/lib/neo4j.rb +0 -119
- data/lib/neo4j/active_rel/callbacks.rb +0 -21
- data/lib/neo4j/active_rel/validations.rb +0 -8
- data/lib/neo4j/core.rb +0 -14
- data/lib/neo4j/version.rb +0 -3
@@ -1,5 +1,5 @@
|
|
1
|
-
module
|
2
|
-
module
|
1
|
+
module ActiveGraph
|
2
|
+
module Node
|
3
3
|
module Dependent
|
4
4
|
# methods used to resolve association dependencies
|
5
5
|
module QueryProxyMethods
|
@@ -22,10 +22,10 @@ module Neo4j
|
|
22
22
|
|
23
23
|
# This will match nodes who only have a single relationship of a given type.
|
24
24
|
# It's used by `dependent: :delete_orphans` and `dependent: :destroy_orphans` and may not have much utility otherwise.
|
25
|
-
# @param [
|
25
|
+
# @param [ActiveGraph::Node::HasN::Association] association The Association object used throughout the match.
|
26
26
|
# @param [String, Symbol] other_node The identifier to use for the other end of the chain.
|
27
27
|
# @param [String, Symbol] other_rel The identifier to use for the relationship in the optional match.
|
28
|
-
# @return [
|
28
|
+
# @return [ActiveGraph::Node::Query::QueryProxy]
|
29
29
|
def unique_nodes(association, self_identifer, other_node, other_rel, ids = [])
|
30
30
|
fail 'Only supported by in QueryProxy chains started by an instance' unless source_object
|
31
31
|
return false if send(association.name).empty?
|
@@ -1,5 +1,5 @@
|
|
1
|
-
module
|
2
|
-
module
|
1
|
+
module ActiveGraph
|
2
|
+
module Node
|
3
3
|
module DependentCallbacks
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
@@ -22,8 +22,8 @@ module Neo4j
|
|
22
22
|
unique_query.each_for_destruction(self, &:destroy) if unique_query
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
rel =
|
25
|
+
def callbacks_from_relationship(relationship, direction, other_node)
|
26
|
+
rel = relationship_corresponding_rel(relationship, direction, other_node.class).try(:last)
|
27
27
|
public_send("dependent_#{rel.dependent}_callback", rel, [other_node.id]) if rel && rel.dependent
|
28
28
|
end
|
29
29
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph::Node
|
2
2
|
module Enum
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
include
|
4
|
+
include ActiveGraph::Shared::Enum
|
5
5
|
|
6
6
|
module ClassMethods
|
7
7
|
protected
|
8
8
|
|
9
9
|
def define_property(property_name, *args)
|
10
10
|
super
|
11
|
-
|
11
|
+
ActiveGraph::ModelSchema.add_required_index(self, property_name) unless args[1][:_index] == false
|
12
12
|
end
|
13
13
|
|
14
14
|
def define_enum_methods(property_name, enum_keys, options)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph::Node
|
2
2
|
module HasN
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
class NonPersistedNodeError <
|
6
|
-
class HasOneConstraintError <
|
5
|
+
class NonPersistedNodeError < ActiveGraph::Error; end
|
6
|
+
class HasOneConstraintError < ActiveGraph::Error; end
|
7
7
|
# Return this object from associations
|
8
8
|
# It uses a QueryProxy to get results
|
9
9
|
# But also caches results and can have results cached on it
|
@@ -23,7 +23,7 @@ module Neo4j::ActiveNode
|
|
23
23
|
# States:
|
24
24
|
# Default
|
25
25
|
def inspect
|
26
|
-
formatted_nodes = ::
|
26
|
+
formatted_nodes = ::ActiveGraph::Node::NodeListFormatter.new(result_nodes)
|
27
27
|
"#<AssociationProxy #{@query_proxy.context} #{formatted_nodes.inspect}>"
|
28
28
|
end
|
29
29
|
|
@@ -87,7 +87,7 @@ module Neo4j::ActiveNode
|
|
87
87
|
|
88
88
|
def result_ids
|
89
89
|
result.map do |object|
|
90
|
-
object.is_a?(
|
90
|
+
object.is_a?(ActiveGraph::Node) ? object.id : object
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
@@ -151,8 +151,8 @@ module Neo4j::ActiveNode
|
|
151
151
|
target = target_for_missing_method(method_name)
|
152
152
|
super if target.nil?
|
153
153
|
|
154
|
-
cache_query_proxy_result if !cached? && !target.is_a?(
|
155
|
-
clear_cache_result if target.is_a?(
|
154
|
+
cache_query_proxy_result if !cached? && !target.is_a?(ActiveGraph::Node::Query::QueryProxy)
|
155
|
+
clear_cache_result if target.is_a?(ActiveGraph::Node::Query::QueryProxy)
|
156
156
|
|
157
157
|
target.public_send(method_name, *args, &block)
|
158
158
|
end
|
@@ -165,7 +165,7 @@ module Neo4j::ActiveNode
|
|
165
165
|
|
166
166
|
def map_results_as_nodes(result)
|
167
167
|
result.map do |object|
|
168
|
-
object.is_a?(
|
168
|
+
object.is_a?(ActiveGraph::Node) ? object : @query_proxy.model.find(object)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -241,8 +241,8 @@ module Neo4j::ActiveNode
|
|
241
241
|
reverse_assoc && reverse_assoc.last
|
242
242
|
end
|
243
243
|
|
244
|
-
def
|
245
|
-
rel =
|
244
|
+
def delete_reverse_has_one_relationship(relationship, direction, other_node)
|
245
|
+
rel = relationship_corresponding_rel(relationship, direction, other_node.class)
|
246
246
|
delete_has_one_rel!(rel.last) if rel && rel.last.type == :has_one
|
247
247
|
end
|
248
248
|
|
@@ -251,10 +251,10 @@ module Neo4j::ActiveNode
|
|
251
251
|
association_proxy_cache.clear
|
252
252
|
end
|
253
253
|
|
254
|
-
def
|
254
|
+
def relationship_corresponding_rel(relationship, direction, target_class)
|
255
255
|
self.class.associations.find do |_key, assoc|
|
256
|
-
assoc.relationship_class_name ==
|
257
|
-
(assoc.relationship_type ==
|
256
|
+
assoc.relationship_class_name == relationship.class.name ||
|
257
|
+
(assoc.relationship_type == relationship.type.to_sym && assoc.target_class == target_class && assoc.direction == direction)
|
258
258
|
end
|
259
259
|
end
|
260
260
|
|
@@ -377,11 +377,11 @@ module Neo4j::ActiveNode
|
|
377
377
|
# Post.has_one :in, :author, type: :has_author, model_class: :Person
|
378
378
|
#
|
379
379
|
# *model_class*: The model class to which the association is referring. Can be a
|
380
|
-
# Symbol/String (or an ``Array`` of same) with the name of the `
|
380
|
+
# Symbol/String (or an ``Array`` of same) with the name of the `Node` class,
|
381
381
|
# `false` to specify any model, or nil to specify that it should be guessed.
|
382
382
|
#
|
383
|
-
# *rel_class*: The ``
|
384
|
-
# model object ``include`` ing ``
|
383
|
+
# *rel_class*: The ``Relationship`` class to use for this association. Can be either a
|
384
|
+
# model object ``include`` ing ``Relationship`` or a Symbol/String (or an ``Array`` of same).
|
385
385
|
# **A Symbol or String is recommended** to avoid load-time issues
|
386
386
|
#
|
387
387
|
# *dependent*: Enables deletion cascading.
|
@@ -402,7 +402,7 @@ module Neo4j::ActiveNode
|
|
402
402
|
#
|
403
403
|
# This would define the methods: ``#vehicle``, ``#vehicle=``, and ``.vehicle``.
|
404
404
|
#
|
405
|
-
# See :ref:`#has_many <Neo4j/
|
405
|
+
# See :ref:`#has_many <Neo4j/Node/HasN/ClassMethods#has_many>` for anything
|
406
406
|
# not specified here
|
407
407
|
#
|
408
408
|
def has_one(direction, name, options = {}) # rubocop:disable Naming/PredicateName
|
@@ -543,7 +543,7 @@ module Neo4j::ActiveNode
|
|
543
543
|
def association_query_proxy(name, options = {})
|
544
544
|
previous_query_proxy = options[:previous_query_proxy] || current_scope
|
545
545
|
query_proxy = previous_query_proxy || default_association_query_proxy
|
546
|
-
|
546
|
+
ActiveGraph::Node::Query::QueryProxy.new(association_target_class(name),
|
547
547
|
associations[name],
|
548
548
|
{driver: neo4j_driver,
|
549
549
|
query_proxy: query_proxy,
|
@@ -577,13 +577,13 @@ module Neo4j::ActiveNode
|
|
577
577
|
end
|
578
578
|
|
579
579
|
def default_association_query_proxy
|
580
|
-
|
580
|
+
ActiveGraph::Node::Query::QueryProxy.new("::#{self.name}".constantize, nil,
|
581
581
|
driver: neo4j_driver, query_proxy: nil, context: self.name.to_s)
|
582
582
|
end
|
583
583
|
|
584
584
|
def build_association(macro, direction, name, options)
|
585
585
|
options[:model_class] = options[:model_class].name if options[:model_class] == self
|
586
|
-
|
586
|
+
ActiveGraph::Node::HasN::Association.new(macro, direction, name, options).tap do |association|
|
587
587
|
add_association(name, association)
|
588
588
|
create_reflection(macro, name, association, self)
|
589
589
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'active_support/inflector/inflections'
|
2
|
-
require '
|
2
|
+
require 'active_graph/class_arguments'
|
3
3
|
|
4
|
-
module
|
5
|
-
module
|
4
|
+
module ActiveGraph
|
5
|
+
module Node
|
6
6
|
module HasN
|
7
7
|
class Association
|
8
|
-
include
|
9
|
-
include
|
10
|
-
include
|
8
|
+
include ActiveGraph::Shared::RelTypeConverters
|
9
|
+
include ActiveGraph::Node::Dependent::AssociationMethods
|
10
|
+
include ActiveGraph::Node::HasN::AssociationCypherMethods
|
11
11
|
|
12
12
|
attr_reader :type, :name, :relationship, :direction, :dependent, :model_class
|
13
13
|
|
@@ -89,7 +89,7 @@ module Neo4j
|
|
89
89
|
|
90
90
|
def discovered_model
|
91
91
|
target_classes.select do |constant|
|
92
|
-
constant.ancestors.include?(::
|
92
|
+
constant.ancestors.include?(::ActiveGraph::Node)
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
@@ -153,7 +153,7 @@ module Neo4j
|
|
153
153
|
private
|
154
154
|
|
155
155
|
def association_model_namespace
|
156
|
-
|
156
|
+
ActiveGraph::Config.association_model_namespace_string
|
157
157
|
end
|
158
158
|
|
159
159
|
def get_direction(create, reverse = false)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph::Node::HasN
|
2
2
|
class Association
|
3
3
|
class RelFactory
|
4
4
|
[:start_object, :other_node_or_nodes, :properties, :association].tap do |accessors|
|
@@ -36,7 +36,7 @@ module Neo4j::ActiveNode::HasN
|
|
36
36
|
Array(other_node_or_nodes).each do |other_node|
|
37
37
|
wrapper = _rel_wrapper(properties)
|
38
38
|
base = _match_query(other_node, wrapper)
|
39
|
-
factory =
|
39
|
+
factory = ActiveGraph::Shared::RelQueryFactory.new(wrapper, wrapper.rel_identifier)
|
40
40
|
factory.base_query = base
|
41
41
|
factory.query.exec
|
42
42
|
end
|
@@ -44,7 +44,7 @@ module Neo4j::ActiveNode::HasN
|
|
44
44
|
|
45
45
|
def _match_query(other_node, wrapper)
|
46
46
|
nodes = _nodes_for_create(other_node, wrapper.from_node_identifier, wrapper.to_node_identifier)
|
47
|
-
|
47
|
+
ActiveGraph::Base.new_query.match_nodes(nodes)
|
48
48
|
end
|
49
49
|
|
50
50
|
def _nodes_for_create(other_node, from_node_id, to_node_id)
|
@@ -54,7 +54,7 @@ module Neo4j::ActiveNode::HasN
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def _rel_wrapper(properties)
|
57
|
-
|
57
|
+
ActiveGraph::Node::HasN::Association::RelWrapper.new(association, properties)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class
|
2
|
-
# Provides the interface needed to interact with the
|
1
|
+
class ActiveGraph::Node::HasN::Association
|
2
|
+
# Provides the interface needed to interact with the Relationship query factory.
|
3
3
|
class RelWrapper
|
4
|
-
include
|
5
|
-
include
|
4
|
+
include ActiveGraph::Shared::Cypher::RelIdentifiers
|
5
|
+
include ActiveGraph::Shared::Cypher::CreateMethod
|
6
6
|
|
7
7
|
attr_reader :type, :association
|
8
8
|
attr_accessor :properties
|
@@ -1,16 +1,16 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph::Node
|
2
2
|
# This module makes it possible to use other IDs than the build it neo4j id (neo_id)
|
3
3
|
#
|
4
4
|
# @example using generated UUIDs
|
5
5
|
# class Person
|
6
|
-
# include
|
6
|
+
# include ActiveGraph::Node
|
7
7
|
# # creates a 'secret' neo4j property my_uuid which will be used as primary key
|
8
8
|
# id_property :my_uuid, auto: :uuid
|
9
9
|
# end
|
10
10
|
#
|
11
11
|
# @example using user defined ids
|
12
12
|
# class Person
|
13
|
-
# include
|
13
|
+
# include ActiveGraph::Node
|
14
14
|
# property :title
|
15
15
|
# validates :title, :presence => true
|
16
16
|
# id_property :title_id, on: :title_to_url
|
@@ -22,7 +22,7 @@ module Neo4j::ActiveNode
|
|
22
22
|
#
|
23
23
|
# @example using already exsting ids that you don't want a constraint added to
|
24
24
|
# class Person
|
25
|
-
# include
|
25
|
+
# include ActiveGraph::Node
|
26
26
|
# property :title
|
27
27
|
# validates :title, :presence => true
|
28
28
|
# id_property :id, on: :id_builder, constraint: false
|
@@ -198,18 +198,18 @@ module Neo4j::ActiveNode
|
|
198
198
|
return
|
199
199
|
end
|
200
200
|
|
201
|
-
|
201
|
+
ActiveGraph::ModelSchema.add_defined_constraint(self, id_property_name)
|
202
202
|
end
|
203
203
|
|
204
204
|
def warn_constraint_option_false!(id_property_name)
|
205
|
-
|
205
|
+
ActiveGraph::Base.logger.warn <<MSG
|
206
206
|
WARNING: The constraint option for id_property is no longer supported (Used on #{self.name}.#{id_property_name}).
|
207
207
|
Since you specified `constraint: false` this option can simply be removed.
|
208
208
|
MSG
|
209
209
|
end
|
210
210
|
|
211
211
|
def id_property_name_type_value
|
212
|
-
name, type, value =
|
212
|
+
name, type, value = ActiveGraph::Config.to_hash.values_at('id_property', 'id_property_type', 'id_property_type_value')
|
213
213
|
|
214
214
|
unless name == :neo_id || (name && type && value)
|
215
215
|
name = :uuid
|
@@ -1,11 +1,11 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph::Node::Initialize
|
2
2
|
extend ActiveSupport::Concern
|
3
|
-
include
|
3
|
+
include ActiveGraph::Shared::Initialize
|
4
4
|
|
5
5
|
attr_reader :called_by
|
6
6
|
|
7
7
|
# called when loading the node from the database
|
8
|
-
# @param [
|
8
|
+
# @param [ActiveGraph::Node] persisted_node the node this class wraps
|
9
9
|
# @param [Hash] properties of the persisted node.
|
10
10
|
def init_on_load(persisted_node, properties)
|
11
11
|
self.class.extract_association_attributes!(properties)
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_graph/core/label'
|
2
2
|
|
3
|
-
module
|
4
|
-
module
|
3
|
+
module ActiveGraph
|
4
|
+
module Node
|
5
5
|
# Provides a mapping between neo4j labels and Ruby classes
|
6
6
|
module Labels
|
7
7
|
extend ActiveSupport::Concern
|
8
|
-
include
|
9
|
-
include
|
8
|
+
include ActiveGraph::Node::Labels::Index
|
9
|
+
include ActiveGraph::Node::Labels::Reloading
|
10
10
|
|
11
11
|
WRAPPED_CLASSES = []
|
12
12
|
MODELS_FOR_LABELS_CACHE = {}
|
13
13
|
MODELS_FOR_LABELS_CACHE.clear
|
14
14
|
|
15
15
|
included do |model|
|
16
|
-
|
16
|
+
ActiveGraph::Node::Labels.clear_wrapped_models
|
17
17
|
|
18
|
-
|
18
|
+
ActiveGraph::Node::Labels.add_wrapped_class(model) unless ActiveGraph::Node::Labels._wrapped_classes.include?(model)
|
19
19
|
end
|
20
20
|
|
21
|
-
class RecordNotFound <
|
21
|
+
class RecordNotFound < ActiveGraph::RecordNotFound; end
|
22
22
|
|
23
23
|
# @return the labels
|
24
24
|
# @see Neo4j-core
|
@@ -76,11 +76,11 @@ module Neo4j
|
|
76
76
|
|
77
77
|
def self.clear_wrapped_models
|
78
78
|
MODELS_FOR_LABELS_CACHE.clear
|
79
|
-
|
79
|
+
ActiveGraph::NodeWrapping::CONSTANTS_FOR_LABELS_CACHE.clear
|
80
80
|
end
|
81
81
|
|
82
82
|
module ClassMethods
|
83
|
-
include
|
83
|
+
include ActiveGraph::Node::QueryMethods
|
84
84
|
|
85
85
|
delegate :update_all, to: :all
|
86
86
|
|
@@ -129,14 +129,14 @@ module Neo4j
|
|
129
129
|
@mapped_label_name || label_for_model
|
130
130
|
end
|
131
131
|
|
132
|
-
# @return [
|
132
|
+
# @return [ActiveGraph::Label] the label for this class
|
133
133
|
def mapped_label
|
134
|
-
|
134
|
+
ActiveGraph::Core::Label.new(mapped_label_name)
|
135
135
|
end
|
136
136
|
|
137
137
|
def base_class
|
138
|
-
unless self <
|
139
|
-
fail "#{name} doesn't belong in a hierarchy descending from
|
138
|
+
unless self < ActiveGraph::Node
|
139
|
+
fail "#{name} doesn't belong in a hierarchy descending from Node"
|
140
140
|
end
|
141
141
|
|
142
142
|
if superclass == Object
|
@@ -149,7 +149,7 @@ module Neo4j
|
|
149
149
|
protected
|
150
150
|
|
151
151
|
def mapped_labels
|
152
|
-
mapped_label_names.map { |label_name|
|
152
|
+
mapped_label_names.map { |label_name| ActiveGraph::Label.create(label_name) }
|
153
153
|
end
|
154
154
|
|
155
155
|
def mapped_label_name=(name)
|
@@ -176,7 +176,7 @@ module Neo4j
|
|
176
176
|
|
177
177
|
def find_callbacks!(result)
|
178
178
|
case result
|
179
|
-
when
|
179
|
+
when ActiveGraph::Node
|
180
180
|
result.run_callbacks(:find)
|
181
181
|
when Array
|
182
182
|
result.each { |r| find_callbacks!(r) }
|
@@ -190,11 +190,11 @@ module Neo4j
|
|
190
190
|
end
|
191
191
|
|
192
192
|
def decorated_label_name
|
193
|
-
name = case
|
193
|
+
name = case ActiveGraph::Config[:module_handling]
|
194
194
|
when :demodulize
|
195
195
|
self.name.demodulize
|
196
196
|
when Proc
|
197
|
-
|
197
|
+
ActiveGraph::Config[:module_handling].call self.name
|
198
198
|
else
|
199
199
|
self.name
|
200
200
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph::Node::Labels
|
2
2
|
module Index
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
@@ -9,20 +9,20 @@ module Neo4j::ActiveNode::Labels
|
|
9
9
|
|
10
10
|
# Creates a Neo4j index on given property
|
11
11
|
#
|
12
|
-
# This can also be done on the property directly, see
|
12
|
+
# This can also be done on the property directly, see ActiveGraph::Node::Property::ClassMethods#property.
|
13
13
|
#
|
14
14
|
# @param [Symbol] property the property we want a Neo4j index on
|
15
15
|
#
|
16
16
|
# @example
|
17
17
|
# class Person
|
18
|
-
# include
|
18
|
+
# include ActiveGraph::Node
|
19
19
|
# property :name
|
20
20
|
# index :name
|
21
21
|
# end
|
22
22
|
def index(property)
|
23
|
-
return if
|
23
|
+
return if ActiveGraph::ModelSchema.defined_constraint?(self, property)
|
24
24
|
|
25
|
-
|
25
|
+
ActiveGraph::ModelSchema.add_defined_index(self, property)
|
26
26
|
end
|
27
27
|
|
28
28
|
# Creates a neo4j constraint on this class for given property
|
@@ -30,7 +30,7 @@ module Neo4j::ActiveNode::Labels
|
|
30
30
|
# @example
|
31
31
|
# Person.constraint :name, type: :unique
|
32
32
|
def constraint(property, _constraints = {type: :unique})
|
33
|
-
|
33
|
+
ActiveGraph::ModelSchema.add_defined_constraint(self, property)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|