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,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Migrations
|
3
3
|
extend ActiveSupport::Autoload
|
4
4
|
autoload :Helpers
|
@@ -10,17 +10,17 @@ module Neo4j
|
|
10
10
|
|
11
11
|
class << self
|
12
12
|
def check_for_pending_migrations!
|
13
|
-
return if
|
13
|
+
return if ActiveGraph::Config.configuration['skip_migration_check']
|
14
14
|
|
15
|
-
runner =
|
15
|
+
runner = ActiveGraph::Migrations::Runner.new
|
16
16
|
pending = runner.pending_migrations
|
17
|
-
fail ::
|
17
|
+
fail ::ActiveGraph::PendingMigrationError, pending if pending.any?
|
18
18
|
end
|
19
19
|
|
20
20
|
attr_accessor :currently_running_migrations
|
21
21
|
|
22
22
|
def maintain_test_schema!
|
23
|
-
|
23
|
+
ActiveGraph::Migrations::Runner.new(silenced: true).all
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Migrations
|
3
3
|
class Base
|
4
|
-
include
|
5
|
-
include
|
6
|
-
include
|
7
|
-
include
|
4
|
+
include ActiveGraph::Migrations::Helpers
|
5
|
+
include ActiveGraph::Migrations::Helpers::Schema
|
6
|
+
include ActiveGraph::Migrations::Helpers::IdProperty
|
7
|
+
include ActiveGraph::Migrations::Helpers::Relationships
|
8
8
|
|
9
9
|
def initialize(migration_id, options = {})
|
10
10
|
@migration_id = migration_id
|
@@ -63,11 +63,11 @@ module Neo4j
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def migration_transaction(&block)
|
66
|
-
|
66
|
+
ActiveGraph::Base.run_transaction(transactions?, &block)
|
67
67
|
end
|
68
68
|
|
69
69
|
def log_queries
|
70
|
-
subscriber =
|
70
|
+
subscriber = ActiveGraph::Transaction.subscribe_to_query(&method(:output))
|
71
71
|
yield
|
72
72
|
ensure
|
73
73
|
ActiveSupport::Notifications.unsubscribe(subscriber) if subscriber
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Migrations
|
3
3
|
class CheckPending
|
4
4
|
def initialize(app)
|
@@ -7,10 +7,10 @@ module Neo4j
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
-
latest_migration =
|
10
|
+
latest_migration = ActiveGraph::Migrations::Runner.latest_migration
|
11
11
|
mtime = latest_migration ? latest_migration.version.to_i : 0
|
12
12
|
if @last_check < mtime
|
13
|
-
|
13
|
+
ActiveGraph::Migrations.check_for_pending_migrations!
|
14
14
|
@last_check = mtime
|
15
15
|
end
|
16
16
|
@app.call(env)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'benchmark'
|
2
2
|
|
3
|
-
module
|
3
|
+
module ActiveGraph
|
4
4
|
module Migrations
|
5
5
|
module Helpers
|
6
6
|
extend ActiveSupport::Concern
|
@@ -18,7 +18,7 @@ module Neo4j
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def rename_property(label, old_property, new_property)
|
21
|
-
fail
|
21
|
+
fail ActiveGraph::MigrationError, format(PROPERTY_ALREADY_DEFINED, new_property: new_property, label: label) if property_exists?(label, new_property)
|
22
22
|
by_label(label).set("n.#{new_property} = n.#{old_property}")
|
23
23
|
.remove("n.#{old_property}").exec
|
24
24
|
end
|
@@ -50,7 +50,7 @@ module Neo4j
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def execute(string, params = {})
|
53
|
-
|
53
|
+
ActiveGraph::Base.query(string, params).to_a
|
54
54
|
end
|
55
55
|
|
56
56
|
def say_with_time(message)
|
@@ -67,7 +67,7 @@ module Neo4j
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def query(*args)
|
70
|
-
|
70
|
+
ActiveGraph::Base.new_query(*args)
|
71
71
|
end
|
72
72
|
|
73
73
|
protected
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Migrations
|
3
3
|
module Helpers
|
4
4
|
module IdProperty
|
@@ -27,7 +27,7 @@ module Neo4j
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def id_batch_set(label, id_property, new_ids, count)
|
30
|
-
tx =
|
30
|
+
tx = ActiveGraph::Base.new_transaction
|
31
31
|
|
32
32
|
execute("MATCH (n:`#{label}`) WHERE NOT EXISTS(n.#{id_property})
|
33
33
|
with COLLECT(n) as nodes, #{new_ids} as ids
|
@@ -38,7 +38,7 @@ module Neo4j
|
|
38
38
|
LIMIT #{count}")
|
39
39
|
|
40
40
|
count
|
41
|
-
rescue
|
41
|
+
rescue ActiveGraph::Server::CypherResponse::ResponseError, Faraday::TimeoutError
|
42
42
|
new_max_per_batch = (max_per_batch * 0.8).round
|
43
43
|
output "Error querying #{max_per_batch} nodes. Trying #{new_max_per_batch}"
|
44
44
|
new_max_per_batch
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Migrations
|
3
3
|
module Helpers
|
4
4
|
module Schema
|
@@ -9,7 +9,7 @@ module Neo4j
|
|
9
9
|
def add_constraint(label, property, options = {})
|
10
10
|
force = options[:force] || false
|
11
11
|
type = options[:type] || :uniqueness
|
12
|
-
label_object =
|
12
|
+
label_object = ActiveGraph::Base.label_object(label)
|
13
13
|
if label_object.constraint?(property)
|
14
14
|
if force
|
15
15
|
label_object.drop_constraint(property, type: type)
|
@@ -22,7 +22,7 @@ module Neo4j
|
|
22
22
|
|
23
23
|
def add_index(label, property, options = {})
|
24
24
|
force = options[:force] || false
|
25
|
-
label_object =
|
25
|
+
label_object = ActiveGraph::Base.label_object(label)
|
26
26
|
if label_object.index?(property)
|
27
27
|
if force
|
28
28
|
label_object.drop_index(property)
|
@@ -35,13 +35,13 @@ module Neo4j
|
|
35
35
|
|
36
36
|
def drop_constraint(label, property, options = {})
|
37
37
|
type = options[:type] || :uniqueness
|
38
|
-
label_object =
|
38
|
+
label_object = ActiveGraph::Base.label_object(label)
|
39
39
|
fail_missing_constraint_or_index!(:constraint, label, property) if !options[:force] && !label_object.constraint?(property)
|
40
40
|
label_object.drop_constraint(property, type: type)
|
41
41
|
end
|
42
42
|
|
43
43
|
def drop_index(label, property, options = {})
|
44
|
-
label_object =
|
44
|
+
label_object = ActiveGraph::Base.label_object(label)
|
45
45
|
fail_missing_constraint_or_index!(:index, label, property) if !options[:force] && !label_object.index?(property)
|
46
46
|
label_object.drop_index(property)
|
47
47
|
end
|
@@ -49,12 +49,12 @@ module Neo4j
|
|
49
49
|
protected
|
50
50
|
|
51
51
|
def fail_missing_constraint_or_index!(type, label, property)
|
52
|
-
fail
|
52
|
+
fail ActiveGraph::MigrationError,
|
53
53
|
format(MISSING_CONSTRAINT_OR_INDEX, type: type, label: label, property: property)
|
54
54
|
end
|
55
55
|
|
56
56
|
def fail_duplicate_constraint_or_index!(type, label, property)
|
57
|
-
fail
|
57
|
+
fail ActiveGraph::MigrationError,
|
58
58
|
format(DUPLICATE_CONSTRAINT_OR_INDEX, type: type, label: label, property: property)
|
59
59
|
end
|
60
60
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
module Migrations
|
3
3
|
class Runner
|
4
4
|
STATUS_TABLE_FORMAT = '%-10s %-20s %s'.freeze
|
@@ -57,10 +57,10 @@ module Neo4j
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def mark_versions_as_complete(versions)
|
60
|
-
|
60
|
+
ActiveGraph::Base.new_query
|
61
61
|
.with('$versions AS versions').params(versions: versions).break
|
62
62
|
.unwind(version: :versions).break
|
63
|
-
.merge('(:`
|
63
|
+
.merge('(:`ActiveGraph::Migrations::SchemaMigration` {migration_id: version})')
|
64
64
|
.exec
|
65
65
|
end
|
66
66
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'set'
|
2
|
-
module
|
2
|
+
module ActiveGraph
|
3
3
|
# This is here to support the removed functionality of being able to
|
4
4
|
# defined indexes and constraints on models
|
5
5
|
# This code should be removed later
|
@@ -32,7 +32,7 @@ module Neo4j
|
|
32
32
|
def model_constraints
|
33
33
|
return @model_constraints if @model_constraints
|
34
34
|
|
35
|
-
constraints =
|
35
|
+
constraints = ActiveGraph::Transaction.constraints.each_with_object({}) do |row, result|
|
36
36
|
result[row[:label]] ||= []
|
37
37
|
result[row[:label]] << row[:properties]
|
38
38
|
end
|
@@ -43,7 +43,7 @@ module Neo4j
|
|
43
43
|
def model_indexes
|
44
44
|
return @model_indexes if @model_indexes
|
45
45
|
|
46
|
-
indexes =
|
46
|
+
indexes = ActiveGraph::Transaction.indexes.each_with_object({}) do |row, result|
|
47
47
|
result[row[:label]] ||= []
|
48
48
|
result[row[:label]] << row[:properties]
|
49
49
|
end
|
@@ -66,16 +66,16 @@ module Neo4j
|
|
66
66
|
|
67
67
|
def ensure_model_data_state!
|
68
68
|
# If we load a new model, reset everything
|
69
|
-
if @previously_loaded_models_count !=
|
69
|
+
if @previously_loaded_models_count != ActiveGraph::Node.loaded_classes.size
|
70
70
|
# Make sure we've finalized id_property details and have called
|
71
71
|
# add_ constraint/index methods above
|
72
|
-
|
72
|
+
ActiveGraph::Node.loaded_classes.each(&:ensure_id_property_info!)
|
73
73
|
reload_models_data!
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
def reload_models_data!
|
78
|
-
@previously_loaded_models_count =
|
78
|
+
@previously_loaded_models_count = ActiveGraph::Node.loaded_classes.size
|
79
79
|
@model_indexes = @model_constraints = nil
|
80
80
|
end
|
81
81
|
|
@@ -101,7 +101,7 @@ module Neo4j
|
|
101
101
|
|
102
102
|
return if messages.values.all?(&:empty?)
|
103
103
|
|
104
|
-
fail ::
|
104
|
+
fail ::ActiveGraph::DeprecatedSchemaDefinitionError, validation_error_message(messages)
|
105
105
|
end
|
106
106
|
|
107
107
|
def validation_error_message(messages)
|
@@ -122,7 +122,7 @@ MSG
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def log_warning!(index_or_constraint, model, property_name)
|
125
|
-
|
125
|
+
ActiveGraph::Base.logger.warn "WARNING: The #{index_or_constraint} option is no longer supported (Defined on #{model.name} for #{property_name})"
|
126
126
|
end
|
127
127
|
|
128
128
|
private
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ActiveGraph
|
2
2
|
# Makes Neo4j nodes and relationships behave like ActiveRecord objects.
|
3
3
|
# By including this module in your class it will create a mapping for the node to your ruby class
|
4
4
|
# by using a Neo4j Label with the same name as the class. When the node is loaded from the database it
|
@@ -7,45 +7,45 @@ module Neo4j
|
|
7
7
|
# in a new object of that class.
|
8
8
|
#
|
9
9
|
# = ClassMethods
|
10
|
-
# * {
|
11
|
-
# * {
|
12
|
-
# * {
|
10
|
+
# * {ActiveGraph::Node::Labels::ClassMethods} defines methods like: <tt>index</tt> and <tt>find</tt>
|
11
|
+
# * {ActiveGraph::Node::Persistence::ClassMethods} defines methods like: <tt>create</tt> and <tt>create!</tt>
|
12
|
+
# * {ActiveGraph::Node::Property::ClassMethods} defines methods like: <tt>property</tt>.
|
13
13
|
#
|
14
14
|
# @example Create a Ruby wrapper for a Neo4j Node
|
15
15
|
# class Company
|
16
|
-
# include
|
16
|
+
# include ActiveGraph::Node
|
17
17
|
# property :name
|
18
18
|
# end
|
19
19
|
# company = Company.new
|
20
20
|
# company.name = 'My Company AB'
|
21
21
|
# Company.save
|
22
22
|
#
|
23
|
-
module
|
23
|
+
module Node
|
24
24
|
extend ActiveSupport::Concern
|
25
25
|
|
26
26
|
MARSHAL_INSTANCE_VARIABLES = [:@attributes, :@_persisted_obj, :@default_property_value]
|
27
27
|
|
28
|
-
include
|
29
|
-
include
|
30
|
-
include
|
31
|
-
include
|
32
|
-
include
|
33
|
-
include
|
34
|
-
include
|
35
|
-
include
|
36
|
-
include
|
37
|
-
include
|
38
|
-
include
|
39
|
-
include
|
40
|
-
include
|
41
|
-
include
|
42
|
-
include
|
43
|
-
include
|
44
|
-
include
|
45
|
-
include
|
46
|
-
include
|
47
|
-
include
|
48
|
-
include
|
28
|
+
include ActiveGraph::Shared
|
29
|
+
include ActiveGraph::Shared::Identity
|
30
|
+
include ActiveGraph::Shared::Marshal
|
31
|
+
include ActiveGraph::Node::Initialize
|
32
|
+
include ActiveGraph::Node::IdProperty
|
33
|
+
include ActiveGraph::Shared::SerializedProperties
|
34
|
+
include ActiveGraph::Node::Property
|
35
|
+
include ActiveGraph::Node::Reflection
|
36
|
+
include ActiveGraph::Node::Persistence
|
37
|
+
include ActiveGraph::Node::Validations
|
38
|
+
include ActiveGraph::Node::Callbacks
|
39
|
+
include ActiveGraph::Node::Query
|
40
|
+
include ActiveGraph::Node::Labels
|
41
|
+
include ActiveGraph::Node::Rels
|
42
|
+
include ActiveGraph::Node::Unpersisted
|
43
|
+
include ActiveGraph::Node::HasN
|
44
|
+
include ActiveGraph::Node::Scope
|
45
|
+
include ActiveGraph::Node::Dependent
|
46
|
+
include ActiveGraph::Node::Enum
|
47
|
+
include ActiveGraph::Shared::PermittedAttributes
|
48
|
+
include ActiveGraph::Node::DependentCallbacks
|
49
49
|
|
50
50
|
def initialize(args = nil)
|
51
51
|
self.class.ensure_id_property_info! # So that we make sure all objects have an id_property
|
@@ -66,7 +66,7 @@ module Neo4j
|
|
66
66
|
|
67
67
|
module ClassMethods
|
68
68
|
def nodeify(object)
|
69
|
-
if object.is_a?(::
|
69
|
+
if object.is_a?(::ActiveGraph::Node) || object.nil?
|
70
70
|
object
|
71
71
|
else
|
72
72
|
self.find(object)
|
@@ -75,7 +75,7 @@ module Neo4j
|
|
75
75
|
end
|
76
76
|
|
77
77
|
included do
|
78
|
-
include
|
78
|
+
include ActiveGraph::Timestamps if ActiveGraph::Config[:record_timestamps]
|
79
79
|
LOADED_CLASSES << self
|
80
80
|
|
81
81
|
def self.inherited?
|
@@ -83,7 +83,7 @@ module Neo4j
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def self.inherited(other)
|
86
|
-
|
86
|
+
ActiveGraph::Node::Labels.clear_wrapped_models
|
87
87
|
|
88
88
|
LOADED_CLASSES << other
|
89
89
|
other.instance_variable_set('@inherited', true)
|
@@ -92,7 +92,7 @@ module Neo4j
|
|
92
92
|
other.inherit_property k.to_sym, v.clone, declared_properties[k].options
|
93
93
|
end
|
94
94
|
|
95
|
-
|
95
|
+
ActiveGraph::Node::Labels.add_wrapped_class(other)
|
96
96
|
super
|
97
97
|
end
|
98
98
|
|
@@ -104,6 +104,6 @@ module Neo4j
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
ActiveSupport.run_load_hooks(:
|
107
|
+
ActiveSupport.run_load_hooks(:node, self)
|
108
108
|
end
|
109
109
|
end
|