activegraph 10.0.0.pre.beta.7 → 10.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -5
  3. data/README.md +21 -17
  4. data/activegraph.gemspec +1 -1
  5. data/lib/active_graph/class_arguments.rb +1 -1
  6. data/lib/active_graph/core.rb +5 -6
  7. data/lib/active_graph/core/entity.rb +11 -0
  8. data/lib/active_graph/core/node.rb +3 -11
  9. data/lib/active_graph/migrations/schema.rb +1 -1
  10. data/lib/active_graph/node/has_n.rb +1 -1
  11. data/lib/active_graph/node/has_n/association.rb +1 -1
  12. data/lib/active_graph/node/initialize.rb +1 -1
  13. data/lib/active_graph/node/labels.rb +3 -3
  14. data/lib/active_graph/node/node_wrapper.rb +1 -1
  15. data/lib/active_graph/node/persistence.rb +3 -3
  16. data/lib/active_graph/node/query/query_proxy.rb +1 -1
  17. data/lib/active_graph/node/query/query_proxy_eager_loading.rb +1 -1
  18. data/lib/active_graph/node/query/query_proxy_methods.rb +1 -1
  19. data/lib/active_graph/railtie.rb +17 -16
  20. data/lib/active_graph/relationship.rb +1 -1
  21. data/lib/active_graph/relationship/initialize.rb +3 -3
  22. data/lib/active_graph/relationship/persistence.rb +5 -5
  23. data/lib/active_graph/relationship/persistence/query_factory.rb +1 -1
  24. data/lib/active_graph/relationship/property.rb +1 -4
  25. data/lib/active_graph/relationship/query.rb +2 -2
  26. data/lib/active_graph/relationship/rel_wrapper.rb +5 -5
  27. data/lib/active_graph/relationship/types.rb +6 -8
  28. data/lib/active_graph/shared/attributes.rb +1 -1
  29. data/lib/active_graph/shared/callbacks.rb +1 -1
  30. data/lib/active_graph/shared/declared_properties.rb +2 -2
  31. data/lib/active_graph/shared/identity.rb +1 -1
  32. data/lib/active_graph/shared/mass_assignment.rb +1 -2
  33. data/lib/active_graph/shared/persistence.rb +8 -8
  34. data/lib/active_graph/shared/property.rb +1 -1
  35. data/lib/active_graph/shared/query_factory.rb +1 -1
  36. data/lib/active_graph/undeclared_properties.rb +1 -1
  37. data/lib/active_graph/version.rb +1 -1
  38. data/lib/rails/generators/active_graph/model/templates/migration.erb +2 -0
  39. metadata +9 -9
  40. data/lib/active_graph/core/relationship.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2902297d95b7e8850de1e878b4adb9187ccba6cd40cfbb803717cb9175097923
4
- data.tar.gz: 74884302b9d3990d944d809d67809037d5544411e748a203ab54710e91d51b1b
3
+ metadata.gz: 66259444a09dbe560ec1a284b7c1988b24eaf4b29386efb63664cef081edf520
4
+ data.tar.gz: ec43759b43c92f62a93589225207e0d37ef1d18ee4b61d5f4f204b89b8985787
5
5
  SHA512:
6
- metadata.gz: dcbb938142991fcd1b4f3fd0def043448953cd1068ce40f44c04cd36b553f220b350c9f1bd80456142f3247312d2b8dfd2fbfba2a19aa0be99fbcc668ee8d39a
7
- data.tar.gz: 8c694ef8ad6767e06fb93d6407052e5e4ef698f19c2ac774ca59448eca9e09a9e2da7791b0a3282f6990328e7efb7e28b2d69e5d258981e65f99112ea1496c80
6
+ metadata.gz: ec40cecc16c133c065672a3aa37360c304bba5cf24fe430dda7a789885262a7b239b798a7998b6d96b34ba8d05d5d0376c134dc829d6db0800e392fb740c0ec7
7
+ data.tar.gz: 9f7fc129cf6916cdf69373ebb789ff7bc5f6c38c675d3e51403c4b0e6e7135a9649cfb2f3f754634507979a371de2a6a16f8670c765e38a016627c21f04e8535
@@ -3,11 +3,24 @@ All notable changes to this project will be documented in this file.
3
3
  This file should follow the standards specified on [http://keepachangelog.com/]
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
- ## [10.0.x] 2020-01-23
7
-
8
- - Executing relationship callbacks on relationship deletion.
9
- - When assiging relationships, preserving earlier relationships.
10
- - Enforcing has one constraint on relationships.
6
+ ## [10.0.0] 2020-07-06
7
+
8
+ - neo4j 4.0 support (default database only)
9
+ - dropped support for neo4j 3.3 or earlier
10
+ - full bolt support
11
+ - full causal cluster support
12
+ - removal of http support
13
+ - removal of embedded support (neo4j embedded is still supported via bolt)
14
+ - support for a neo4j ruby driver with an api of the official drivers
15
+ - discontinuation of the ``neo4j-core`` gem. Its functionality is replaced partially by ``neo4j-ruby-driver`` and
16
+ partially by ``activegraph``
17
+ - higher naming consistency with ``activerecord`` and the official ``neo4j-java-driver``
18
+ - configuration more consistent with ``activerecord``
19
+ - changed transaction API
20
+ - support for sessions with bookmarks and read and write transaction
21
+ - enforcing has one constraint on relationships
22
+ - better handling of has_many (no deletion and recreation)
23
+ - executing association callbacks on relationship deletion
11
24
 
12
25
  ## [9.6.1] 2019-12-18
13
26
 
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  ### Documentation
13
13
 
14
- All new documentation will be done via our [readthedocs](http://neo4jrb.readthedocs.org) site, though some old documentation has yet to be moved from our [wiki](https://github.com/neo4jrb/neo4j/wiki) (also there is the [neo4j-core wiki](https://github.com/neo4jrb/neo4j-core/wiki))
14
+ All new documentation will be done via our [readthedocs](http://neo4jrb.readthedocs.org) site, though some old documentation has yet to be moved from our [wiki](https://github.com/neo4jrb/neo4j/wiki)
15
15
 
16
16
  ### Contact Us
17
17
 
@@ -45,27 +45,31 @@ Neo4j.rb v4.1.0 was released in January of 2015. Its changes are outlined [here]
45
45
 
46
46
  ## Neo4j version support
47
47
 
48
- | **Neo4j Version** | v2.x | v3.x | >= v4.x | >= 7.0.3 |
49
- |-------------------|------|-------|---------|----------|
50
- | 1.9.x | Yes | No | No | No |
51
- | 2.0.x | No | Yes | No | No |
52
- | 2.1.x | No | Yes | Yes * | Yes |
53
- | 2.2.x | No | No | Yes | Yes |
54
- | 2.3.x | No | No | Yes | Yes |
55
- | >= 3.0.0 | No | No | No | Yes |
48
+ | **Neo4j Version** | v2.x | v3.x | >= v4.x | >= 7.0.3 | activegraph 10.0 |
49
+ |-------------------|------|-------|---------|----------|------------------|
50
+ | 1.9.x | Yes | No | No | No | No |
51
+ | 2.0.x | No | Yes | No | No | No |
52
+ | 2.1.x | No | Yes | Yes * | Yes | No |
53
+ | 2.2.x | No | No | Yes | Yes | No |
54
+ | 2.3.x | No | No | Yes | Yes | No |
55
+ | 3.0, 3.1, 3.3 | No | No | No | Yes | No |
56
+ | 3.4, 3.5 | No | No | No | Yes | Yes |
57
+ | 4.0 | No | No | No | No | Yes |
58
+ | 4.1 | No | No | No | No | No |
56
59
 
57
60
  `*` Neo4j.rb >= 4.x doesn't support Neo4j versions before 2.1.5. To use 2.1.x you should upgrade to a version >= 2.1.5
58
61
 
59
62
  ## Neo4j feature support
60
63
 
61
- | **Neo4j Feature** | v2.x | v3.x | >= v4.x | >= 8.x |
62
- |----------------------------|--------|------|---------|--------|
63
- | Bolt Protocol | No | No | No | Yes |
64
- | Auth | No | No | Yes | Yes |
65
- | Remote Cypher | Yes | Yes | Yes | Yes |
66
- | Transactions | Yes | Yes | Yes | Yes |
67
- | High Availability | No | Yes | Yes | Yes |
68
- | Embedded JVM support | Yes | Yes | Yes | Yes |
64
+ | **Neo4j Feature** | v2.x | v3.x | >= v4.x | >= 8.x | activegraph 10.0 |
65
+ |----------------------------|--------|------|---------|--------|------------------|
66
+ | Bolt Protocol | No | No | No | Yes | Yes |
67
+ | Auth | No | No | Yes | Yes | Yes |
68
+ | Remote Cypher | Yes | Yes | Yes | Yes | No |
69
+ | Transactions | Yes | Yes | Yes | Yes | Yes |
70
+ | High Availability | No | Yes | Yes | Yes | Yes |
71
+ | Causal Cluster | No | No | No | No | Yes |
72
+ | Embedded JVM support | Yes | Yes | Yes | Yes | via bolt only |
69
73
 
70
74
  ## Documentation
71
75
 
@@ -38,7 +38,7 @@ DESCRIPTION
38
38
  s.add_development_dependency('guard-rspec')
39
39
  s.add_development_dependency('guard-rubocop')
40
40
  s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
41
- s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '>= 0.4.0')
41
+ s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '~> 1.7.0')
42
42
  s.add_development_dependency('os')
43
43
  s.add_development_dependency('pry')
44
44
  s.add_development_dependency('railties', '>= 4.0')
@@ -1,7 +1,7 @@
1
1
  module ActiveGraph
2
2
  module ClassArguments
3
3
  class << self
4
- INVALID_CLASS_ARGUMENT_ERROR = 'option must by String, Symbol, false, nil, or an Array of Symbols/Strings'
4
+ INVALID_CLASS_ARGUMENT_ERROR = 'option must be String, Symbol, false, nil, or an Array of Symbols/Strings'
5
5
 
6
6
  def valid_argument?(class_argument)
7
7
  [NilClass, String, Symbol, FalseClass].include?(class_argument.class) ||
@@ -1,15 +1,14 @@
1
- require 'active_graph/transaction'
2
1
  require 'active_graph/core/instrumentable'
2
+ require 'active_graph/core/entity'
3
+ require 'active_graph/core/node'
3
4
  require 'active_graph/core/query'
4
5
  require 'active_graph/core/record'
5
-
6
- require 'neo4j_ruby_driver'
7
6
  require 'active_graph/core/wrappable'
8
- require 'active_graph/core/node'
9
- require 'active_graph/core/relationship'
7
+ require 'active_graph/transaction'
8
+ require 'neo4j_ruby_driver'
10
9
 
11
10
  Neo4j::Driver::Types::Entity.include ActiveGraph::Core::Wrappable
11
+ Neo4j::Driver::Types::Entity.prepend ActiveGraph::Core::Entity
12
12
  Neo4j::Driver::Types::Node.prepend ActiveGraph::Core::Node
13
- Neo4j::Driver::Types::Relationship.include ActiveGraph::Core::Relationship
14
13
  Neo4j::Driver::StatementResult.prepend ActiveGraph::Core::Result
15
14
  Neo4j::Driver::Record.prepend ActiveGraph::Core::Record
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveGraph
4
+ module Core
5
+ module Entity
6
+ def properties
7
+ @properties ||= super
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,23 +1,15 @@
1
- require 'active_graph/core/wrappable'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module ActiveGraph
4
4
  module Core
5
5
  module Node
6
- def props; properties; end
7
- # Perhaps we should deprecate this?
8
- def neo_id; id; end
9
-
10
- def ==(other)
11
- other.is_a?(Node) && neo_id == other.neo_id
6
+ def neo_id
7
+ id
12
8
  end
13
9
 
14
10
  def labels
15
11
  @labels ||= super
16
12
  end
17
-
18
- def properties
19
- @properties ||= super
20
- end
21
13
  end
22
14
  end
23
15
  end
@@ -19,7 +19,7 @@ module ActiveGraph
19
19
  private
20
20
 
21
21
  def fetch_constraint_descriptions
22
- ActiveGraph::Base.query('CALL db.constraints()').map(&:description)
22
+ ActiveGraph::Base.query('CALL db.constraints() YIELD description').map(&:first)
23
23
  end
24
24
 
25
25
  def fetch_index_descriptions
@@ -402,7 +402,7 @@ module ActiveGraph::Node
402
402
  #
403
403
  # This would define the methods: ``#vehicle``, ``#vehicle=``, and ``.vehicle``.
404
404
  #
405
- # See :ref:`#has_many <Neo4j/Node/HasN/ClassMethods#has_many>` for anything
405
+ # See :ref:`#has_many <ActiveGraph/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
@@ -121,7 +121,7 @@ module ActiveGraph
121
121
  attr_reader :relationship_class_name
122
122
 
123
123
  def relationship_class_type
124
- relationship_class._type.to_sym
124
+ relationship_class.type.to_sym
125
125
  end
126
126
 
127
127
  def relationship_class
@@ -16,6 +16,6 @@ module ActiveGraph::Node::Initialize
16
16
 
17
17
  def init_on_reload(reloaded)
18
18
  @attributes = nil
19
- init_on_load(reloaded, reloaded.props)
19
+ init_on_load(reloaded, reloaded.properties)
20
20
  end
21
21
  end
@@ -21,7 +21,7 @@ module ActiveGraph
21
21
  class RecordNotFound < ActiveGraph::RecordNotFound; end
22
22
 
23
23
  # @return the labels
24
- # @see Neo4j-core
24
+ # @see ActiveGraph::Core
25
25
  def labels
26
26
  @_persisted_obj.labels
27
27
  end
@@ -32,7 +32,7 @@ module ActiveGraph
32
32
  # end
33
33
 
34
34
  # adds one or more labels
35
- # @see Neo4j-core
35
+ # @see ActiveGraph::Core
36
36
  def add_labels(*labels)
37
37
  labels.inject(query_as(:n)) do |query, label|
38
38
  query.set("n:`#{label}`")
@@ -43,7 +43,7 @@ module ActiveGraph
43
43
 
44
44
  # Removes one or more labels
45
45
  # Be careful, don't remove the label representing the Ruby class.
46
- # @see Neo4j-core
46
+ # @see ActiveGraph::Core
47
47
  def remove_labels(*labels)
48
48
  labels.inject(query_as(:n)) do |query, label|
49
49
  query.remove("n:`#{label}`")
@@ -6,7 +6,7 @@ wrapping_proc = proc do |node|
6
6
  next node if not found_class
7
7
 
8
8
  found_class.new.tap do |wrapped_node|
9
- wrapped_node.init_on_load(node, node.props)
9
+ wrapped_node.init_on_load(node, node.properties)
10
10
  end
11
11
  end
12
12
  Neo4j::Driver::Types::Node.wrapper_callback(wrapping_proc)
@@ -30,8 +30,8 @@ module ActiveGraph::Node
30
30
  end
31
31
 
32
32
  # Increments concurrently a numeric attribute by a centain amount
33
- # @param [Symbol, String] name of the attribute to increment
34
- # @param [Integer, Float] amount to increment
33
+ # @param [Symbol, String] attribute name of the attribute to increment
34
+ # @param [Integer, Float] by amount to increment
35
35
  def concurrent_increment!(attribute, by = 1)
36
36
  increment_by_query! query_as(:n), attribute, by
37
37
  end
@@ -55,7 +55,7 @@ module ActiveGraph::Node
55
55
  # @return true
56
56
  def create_model
57
57
  node = _create_node(props_for_create)
58
- init_on_load(node, node.props)
58
+ init_on_load(node, node.properties)
59
59
  @deferred_nodes = nil
60
60
  true
61
61
  end
@@ -16,7 +16,7 @@ module ActiveGraph
16
16
  attr_reader :source_object, :association, :model, :starting_query
17
17
 
18
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.
19
+ # it is actually referring to <tt>ActiveGraph::Core::Query</tt>, which is a pure Ruby Cypher DSL provided by the <tt>activegraph</tt> gem.
20
20
  # QueryProxy provides ActiveRecord-like methods for common patterns. When it's not handling CRUD for relationships and queries, it
21
21
  # provides Node's association chaining (`student.lessons.teachers.where(age: 30).hobbies`) and enjoys long walks on the
22
22
  # beach.
@@ -62,7 +62,7 @@ module ActiveGraph
62
62
  if rel.is_a?(ActiveGraph::Relationship)
63
63
  rel.instance_variable_set(direction == :in ? '@from_node' : '@to_node', node)
64
64
  end
65
- @_cache[direction == :out ? rel.start_node_neo_id : rel.end_node_neo_id]
65
+ @_cache[direction == :out ? rel.start_node_id : rel.end_node_id]
66
66
  .association_proxy(element.name).add_to_cache(node, rel)
67
67
  end
68
68
 
@@ -82,7 +82,7 @@ module ActiveGraph
82
82
 
83
83
  alias blank? empty?
84
84
 
85
- # @param [ActiveGraph::Node, ActiveGraph::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 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)
@@ -2,12 +2,13 @@ require 'active_support/notifications'
2
2
  require 'rails/railtie'
3
3
  # Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
4
4
  require 'action_dispatch/railtie'
5
+ require 'active_graph'
5
6
 
6
7
  module ActiveGraph
7
8
  class Railtie < ::Rails::Railtie
8
9
  def empty_config
9
10
  ActiveSupport::OrderedOptions.new.tap do |cfg|
10
- cfg.driver = ActiveSupport::OrderedOptions.new.tap { |cfg| cfg.config = ActiveSupport::OrderedOptions.new }
11
+ cfg.driver = ActiveSupport::OrderedOptions.new
11
12
  end
12
13
  end
13
14
 
@@ -58,29 +59,29 @@ module ActiveGraph
58
59
  end
59
60
  end
60
61
 
61
- def setup!(neo4j_config = empty_config)
62
- url, path, auth_token, username, password, config =
63
- final_driver_config!(neo4j_config).values_at(:url, :path, :auth_token, :username, :password, :config)
62
+ def setup!(config = empty_config)
63
+ config = final_driver_config!(config)
64
+ scheme = config.delete(:scheme) || 'bolt'
65
+ host = config.delete(:host) || 'localhost'
66
+ port = config.delete(:port) || 7687
67
+ url = config.delete(:url) || URI::Generic.build( scheme: scheme, host: host, port: port ).to_s
68
+ username = config.delete(:username)
69
+ password = config.delete(:password)
70
+ auth_token = config.delete(:auth_token)
64
71
  auth_token ||= username ? Neo4j::Driver::AuthTokens.basic(username, password) : Neo4j::Driver::AuthTokens.none
65
72
  register_neo4j_cypher_logging
66
73
 
67
- Neo4j::Driver::GraphDatabase.driver(url || path || default_driver_path_or_url, auth_token, config)
74
+ method = url.is_a?(Enumerable) ? :routing_driver : :driver
75
+ Neo4j::Driver::GraphDatabase.send(method, url, auth_token, config)
68
76
  end
69
77
 
70
- def final_driver_config!(neo4j_config)
71
- (neo4j_config[:driver].empty? ? yaml_config_data : neo4j_config[:driver]).dup
72
- end
73
-
74
- def default_driver_path_or_url
75
- ENV['NEO4J_URL'] || ENV['NEO4J_PATH'] || 'bolt://localhost:7474'
78
+ def final_driver_config!(config)
79
+ { url: ENV['NEO4J_URL'] }.compact.merge(config[:driver]).merge(yaml_config_data)
76
80
  end
77
81
 
78
82
  def yaml_config_data
79
- @yaml_config_data ||= if yaml_path
80
- HashWithIndifferentAccess.new(YAML.load(ERB.new(yaml_path.read).result)[Rails.env])
81
- else
82
- {}
83
- end
83
+ @yaml_config_data ||=
84
+ yaml_path ? YAML.load(ERB.new(yaml_path.read).result)[Rails.env].transform_keys!(&:to_sym) : {}
84
85
  end
85
86
 
86
87
  def yaml_path
@@ -4,7 +4,7 @@ module ActiveGraph
4
4
  module Relationship
5
5
  extend ActiveSupport::Concern
6
6
 
7
- MARSHAL_INSTANCE_VARIABLES = [:@attributes, :@rel_type, :@_persisted_obj]
7
+ MARSHAL_INSTANCE_VARIABLES = [:@attributes, :@type, :@_persisted_obj]
8
8
 
9
9
  include ActiveGraph::Shared
10
10
  include ActiveGraph::Relationship::Initialize
@@ -9,10 +9,10 @@ module ActiveGraph::Relationship
9
9
  # @param [ActiveGraph::Relationship] to_node_id The neo_id of the ending node of this rel
10
10
  # @param [String] type the relationship type
11
11
  def init_on_load(persisted_rel, from_node_id, to_node_id, type)
12
- @rel_type = type
12
+ @type = type
13
13
  @_persisted_obj = persisted_rel
14
14
  changed_attributes_clear!
15
- @attributes = convert_and_assign_attributes(persisted_rel.props)
15
+ @attributes = convert_and_assign_attributes(persisted_rel.properties)
16
16
  load_nodes(from_node_id, to_node_id)
17
17
  end
18
18
 
@@ -21,7 +21,7 @@ module ActiveGraph::Relationship
21
21
  init_on_load(unwrapped_reloaded,
22
22
  unwrapped_reloaded.start_node_id,
23
23
  unwrapped_reloaded.end_node_id,
24
- unwrapped_reloaded.rel_type)
24
+ unwrapped_reloaded.type)
25
25
  self
26
26
  end
27
27
  end
@@ -37,8 +37,8 @@ module ActiveGraph::Relationship
37
37
  end
38
38
 
39
39
  # Increments concurrently a numeric attribute by a centain amount
40
- # @param [Symbol, String] name of the attribute to increment
41
- # @param [Integer, Float] amount to increment
40
+ # @param [Symbol, String] attribute name of the attribute to increment
41
+ # @param [Integer, Float] by amount to increment
42
42
  def concurrent_increment!(attribute, by = 1)
43
43
  increment_by_query! query_as(:r), attribute, by, :r
44
44
  end
@@ -47,8 +47,8 @@ module ActiveGraph::Relationship
47
47
  validate_node_classes!
48
48
  delete_has_one_rel
49
49
  rel = _create_rel
50
- return self unless rel.respond_to?(:props)
51
- init_on_load(rel, from_node, to_node, @rel_type)
50
+ return self unless rel.respond_to?(:properties)
51
+ init_on_load(rel, from_node, to_node, @type)
52
52
  true
53
53
  end
54
54
 
@@ -65,7 +65,7 @@ module ActiveGraph::Relationship
65
65
 
66
66
  module ClassMethods
67
67
  # Creates a new relationship between objects
68
- # @param [Hash] props the properties the new relationship should have
68
+ # @param [Hash] args the properties the new relationship should have
69
69
  def create(*args)
70
70
  new(*args).tap(&:save)
71
71
  end
@@ -85,7 +85,7 @@ module ActiveGraph::Relationship::Persistence
85
85
  def wrap!(node, res, key)
86
86
  return if node.persisted? || !res.keys.include?(key)
87
87
  unwrapped = res[key]
88
- node.init_on_load(unwrapped, unwrapped.props)
88
+ node.init_on_load(unwrapped, unwrapped.properties)
89
89
  end
90
90
 
91
91
  def node_symbols
@@ -17,16 +17,13 @@ module ActiveGraph::Relationship
17
17
  alias end_node to_node
18
18
 
19
19
  %w(start_node end_node).each do |direction|
20
- define_method("#{direction}_neo_id") { send(direction).neo_id if direction }
20
+ define_method("#{direction}_id") { send(direction).neo_id if direction }
21
21
  end
22
- alias from_node_neo_id start_node_neo_id
23
- alias to_node_neo_id end_node_neo_id
24
22
 
25
23
  # @return [String] a string representing the relationship type that will be created
26
24
  def type
27
25
  self.class.type
28
26
  end
29
- alias rel_type type
30
27
 
31
28
  def initialize(attributes = nil)
32
29
  super(attributes)
@@ -51,12 +51,12 @@ module ActiveGraph::Relationship
51
51
 
52
52
  def where_query
53
53
  deprecation_warning!
54
- ActiveGraph::Base.new_query.match("#{cypher_string(:outbound)}-[r1:`#{self._type}`]->#{cypher_string(:inbound)}")
54
+ ActiveGraph::Base.new_query.match("#{cypher_string(:outbound)}-[r1:`#{type}`]->#{cypher_string(:inbound)}")
55
55
  end
56
56
 
57
57
  def all_query
58
58
  deprecation_warning!
59
- ActiveGraph::Base.new_query.match("#{cypher_string}-[r1:`#{self._type}`]->#{cypher_string(:inbound)}")
59
+ ActiveGraph::Base.new_query.match("#{cypher_string}-[r1:`#{type}`]->#{cypher_string(:inbound)}")
60
60
  end
61
61
 
62
62
  def cypher_string(dir = :outbound)
@@ -1,4 +1,4 @@
1
- require 'active_graph/core/relationship'
1
+ # frozen_string_literal: true
2
2
 
3
3
  wrapping_proc = proc do |relationship|
4
4
  ActiveGraph::RelWrapping.wrapper(relationship)
@@ -9,9 +9,9 @@ module ActiveGraph
9
9
  module RelWrapping
10
10
  class << self
11
11
  def wrapper(rel)
12
- rel.props.symbolize_keys!
12
+ rel.properties.symbolize_keys!
13
13
  begin
14
- most_concrete_class = class_from_type(rel.rel_type).constantize
14
+ most_concrete_class = class_from_type(rel.type).constantize
15
15
  return rel unless most_concrete_class < ActiveGraph::Relationship
16
16
  most_concrete_class.new
17
17
  rescue NameError => e
@@ -23,8 +23,8 @@ module ActiveGraph
23
23
  end
24
24
  end
25
25
 
26
- def class_from_type(rel_type)
27
- ActiveGraph::Relationship::Types::WRAPPED_CLASSES[rel_type] || ActiveGraph::Relationship::Types::WRAPPED_CLASSES[rel_type] = rel_type.to_s.downcase.camelize
26
+ def class_from_type(type)
27
+ ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] || ActiveGraph::Relationship::Types::WRAPPED_CLASSES[type] = type.to_s.downcase.camelize
28
28
  end
29
29
  end
30
30
  end
@@ -14,7 +14,7 @@ module ActiveGraph
14
14
  # and Lesson is 'EnrolledIn'." After all, that is a big part of why we have models, right? To make our lives easier?
15
15
  #
16
16
  # A model is added to WRAPPED_CLASSES when it is initalized AND when the `type` class method is called within a model. This means that
17
- # it's possible a model will be added twice: once with the rel_type version of the model name, again with the custom type. deal_with_it.gif.
17
+ # it's possible a model will be added twice: once with the type version of the model name, again with the custom type. deal_with_it.gif.
18
18
  WRAPPED_CLASSES = {}
19
19
 
20
20
  included do
@@ -34,16 +34,14 @@ module ActiveGraph
34
34
  # @param [Boolean] auto Should the given_type be changed in compliance with the gem's rel decorator setting?
35
35
  def type(given_type = nil, auto = false)
36
36
  case
37
- when !given_type && rel_type?
38
- @rel_type
37
+ when !given_type && type?
38
+ @type
39
39
  when given_type
40
40
  assign_type!(given_type, auto)
41
41
  else
42
42
  assign_type!(namespaced_model_name, true)
43
43
  end
44
44
  end
45
- alias rel_type type
46
- alias _type type # should be deprecated
47
45
 
48
46
  def namespaced_model_name
49
47
  case ActiveGraph::Config[:module_handling]
@@ -65,14 +63,14 @@ module ActiveGraph
65
63
  _wrapped_classes[type.to_sym] = self.name
66
64
  end
67
65
 
68
- def rel_type?
69
- !!@rel_type
66
+ def type?
67
+ !!@type
70
68
  end
71
69
 
72
70
  private
73
71
 
74
72
  def assign_type!(given_type, auto)
75
- @rel_type = (auto ? decorated_rel_type(given_type) : given_type).tap do |type|
73
+ @type = (auto ? decorated_rel_type(given_type) : given_type).tap do |type|
76
74
  add_wrapped_class(type)
77
75
  end
78
76
  end
@@ -189,7 +189,7 @@ module ActiveGraph::Shared
189
189
 
190
190
  # Assign a set of attribute definitions, used when subclassing models
191
191
  #
192
- # @param [Array<ActiveGraph::Shared::DeclaredProperties>] The Array of
192
+ # @param [Array<ActiveGraph::Shared::DeclaredProperties>] attributes The Array of
193
193
  # AttributeDefinition instances
194
194
  def attributes=(attributes)
195
195
  @attributes = attributes
@@ -9,7 +9,7 @@ module ActiveGraph
9
9
 
10
10
  included do
11
11
  include ActiveModel::Validations::Callbacks
12
- # after_find is triggered by the `find` method defined in lib/neo4j/node/id_property.rb
12
+ # after_find is triggered by the `find` method defined in lib/active_graph/node/id_property.rb
13
13
  define_model_callbacks :initialize, :find, only: :after
14
14
  define_model_callbacks :create_commit, :update_commit, :destroy_commit, only: :after
15
15
  define_model_callbacks :save, :create, :update, :destroy, :touch
@@ -75,7 +75,7 @@ module ActiveGraph::Shared
75
75
  end.freeze
76
76
  end
77
77
 
78
- # During object wrapping, a props hash is built with string keys but Neo4j-core provides symbols.
78
+ # During object wrapping, a props hash is built with string keys but ActiveGraph::Core provides symbols.
79
79
  # Rather than a `to_s` or `symbolize_keys` during every load, we build a map of symbol-to-string
80
80
  # to speed up the process. This increases memory used by the gem but reduces object allocation and GC, so it is faster
81
81
  # in practice.
@@ -174,7 +174,7 @@ module ActiveGraph::Shared
174
174
  (value.is_a?(Array) && supports_array?(key)) || !EXCLUDED_TYPES.include?(value.class)
175
175
  end
176
176
 
177
- # @param [Symbol] key An undeclared property value found in the _persisted_obj.props hash.
177
+ # @param [Symbol] key An undeclared property value found in the _persisted_obj.properties hash.
178
178
  # Typically, this is a node's id property, which will not be registered as other properties are.
179
179
  # In the future, this should probably be reworked a bit. This class should either not know or care
180
180
  # about the id property or it should be in charge of it. In the meantime, this improves
@@ -14,7 +14,7 @@ module ActiveGraph
14
14
 
15
15
  # @return [Integer, nil] the neo4j id of the node if persisted or nil
16
16
  def neo_id
17
- _persisted_obj ? _persisted_obj.neo_id : nil
17
+ _persisted_obj ? _persisted_obj.id : nil
18
18
  end
19
19
 
20
20
  def id
@@ -19,9 +19,8 @@ module ActiveGraph::Shared
19
19
  # person.first_name #=> "Chris"
20
20
  # person.last_name #=> "Griego"
21
21
  #
22
- # @param [Hash{#to_s => Object}, #each] attributes Attributes used to
22
+ # @param [Hash{#to_s => Object}, #each] new_attributes Attributes used to
23
23
  # populate the model
24
- # @param [Hash, #[]] options Options that affect mass assignment
25
24
  def assign_attributes(new_attributes = nil)
26
25
  return unless new_attributes.present?
27
26
  new_attributes.each do |name, value|
@@ -13,7 +13,7 @@ module ActiveGraph::Shared
13
13
  return if skip_update?
14
14
  props = props_for_update
15
15
  neo4j_query(query_as(:n).set(n: props))
16
- _persisted_obj.props.merge!(props)
16
+ _persisted_obj.properties.merge!(props)
17
17
  changed_attributes_clear!
18
18
  end
19
19
 
@@ -46,8 +46,8 @@ module ActiveGraph::Shared
46
46
  end
47
47
 
48
48
  # Increments a numeric attribute by a centain amount
49
- # @param [Symbol, String] name of the attribute to increment
50
- # @param [Integer, Float] amount to increment
49
+ # @param [Symbol, String] attribute name of the attribute to increment
50
+ # @param [Integer, Float] by amount to increment
51
51
  def increment(attribute, by = 1)
52
52
  self[attribute] ||= 0
53
53
  self[attribute] += by
@@ -55,15 +55,15 @@ module ActiveGraph::Shared
55
55
  end
56
56
 
57
57
  # Convenience method to increment numeric attribute and #save at the same time
58
- # @param [Symbol, String] name of the attribute to increment
59
- # @param [Integer, Float] amount to increment
58
+ # @param [Symbol, String] attribute name of the attribute to increment
59
+ # @param [Integer, Float] by amount to increment
60
60
  def increment!(attribute, by = 1)
61
61
  increment(attribute, by).update_attribute(attribute, self[attribute])
62
62
  end
63
63
 
64
64
  # Increments concurrently a numeric attribute by a centain amount
65
- # @param [Symbol, String] name of the attribute to increment
66
- # @param [Integer, Float] amount to increment
65
+ # @param [Symbol, String] _attribute name of the attribute to increment
66
+ # @param [Integer, Float] _by amount to increment
67
67
  def concurrent_increment!(_attribute, _by = 1)
68
68
  fail 'not_implemented'
69
69
  end
@@ -197,7 +197,7 @@ module ActiveGraph::Shared
197
197
  db_values = props_for_db(hash)
198
198
  neo4j_query(query_as(:n).set(n: db_values))
199
199
  db_values.each_pair { |k, v| self.public_send(:"#{k}=", v) }
200
- _persisted_obj.props.merge!(db_values)
200
+ _persisted_obj.properties.merge!(db_values)
201
201
  changed_attributes_selective_clear!(db_values)
202
202
  true
203
203
  end
@@ -132,7 +132,7 @@ module ActiveGraph::Shared
132
132
  # Defines a property on the class
133
133
  #
134
134
  # See active_attr gem for allowed options, e.g which type
135
- # Notice, in Neo4j you don't have to declare properties before using them, see the neo4j-core api.
135
+ # Notice, in ActiveGraph you don't have to declare properties before using them, see the ActiveGraph::Coree api.
136
136
  #
137
137
  # @example Without type
138
138
  # class Person
@@ -18,7 +18,7 @@ module ActiveGraph::Shared
18
18
  case
19
19
  when graph_obj.respond_to?(:labels_for_create)
20
20
  NodeQueryFactory
21
- when graph_obj.respond_to?(:rel_type)
21
+ when graph_obj.respond_to?(:type)
22
22
  RelQueryFactory
23
23
  else
24
24
  fail "Unable to find factory for #{graph_obj}"
@@ -16,7 +16,7 @@ module ActiveGraph
16
16
  alias [] read_attribute
17
17
 
18
18
  def read_undeclared_property(name)
19
- _persisted_obj ? _persisted_obj.props[name] : (undeclared_properties && undeclared_properties[name])
19
+ _persisted_obj ? _persisted_obj.properties[name] : (undeclared_properties && undeclared_properties[name])
20
20
  end
21
21
 
22
22
  def write_attribute(name, value)
@@ -1,3 +1,3 @@
1
1
  module ActiveGraph
2
- VERSION = '10.0.0-beta.7'
2
+ VERSION = '10.0.0'
3
3
  end
@@ -1,4 +1,6 @@
1
1
  class Create<%= @migration_class_name.underscore.camelize %> < ActiveGraph::Migrations::Base
2
+ disable_transactions!
3
+
2
4
  def up
3
5
  add_constraint :<%= class_name %>, :uuid
4
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0.pre.beta.7
4
+ version: 10.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -126,16 +126,16 @@ dependencies:
126
126
  name: neo4j-ruby-driver
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 0.4.0
131
+ version: 1.7.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 0.4.0
138
+ version: 1.7.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: os
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +262,7 @@ files:
262
262
  - lib/active_graph/core.rb
263
263
  - lib/active_graph/core/connection_failed_error.rb
264
264
  - lib/active_graph/core/cypher_error.rb
265
+ - lib/active_graph/core/entity.rb
265
266
  - lib/active_graph/core/instrumentable.rb
266
267
  - lib/active_graph/core/label.rb
267
268
  - lib/active_graph/core/logging.rb
@@ -273,7 +274,6 @@ files:
273
274
  - lib/active_graph/core/query_ext.rb
274
275
  - lib/active_graph/core/query_find_in_batches.rb
275
276
  - lib/active_graph/core/record.rb
276
- - lib/active_graph/core/relationship.rb
277
277
  - lib/active_graph/core/result.rb
278
278
  - lib/active_graph/core/schema.rb
279
279
  - lib/active_graph/core/schema_errors.rb
@@ -412,9 +412,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
412
412
  version: '2.5'
413
413
  required_rubygems_version: !ruby/object:Gem::Requirement
414
414
  requirements:
415
- - - ">"
415
+ - - ">="
416
416
  - !ruby/object:Gem::Version
417
- version: 1.3.1
417
+ version: '0'
418
418
  requirements: []
419
419
  rubygems_version: 3.1.2
420
420
  signing_key:
@@ -1,13 +0,0 @@
1
- require 'active_graph/core/wrappable'
2
-
3
- module ActiveGraph
4
- module Core
5
- module Relationship
6
- def props; properties; end
7
- def neo_id; id; end
8
- def start_node_neo_id; start_node_id; end
9
- def end_node_neo_id; end_node_id; end
10
- def rel_type; type; end
11
- end
12
- end
13
- end