Skip to content

Commit

Permalink
renaming the remaining session leftover to driver
Browse files Browse the repository at this point in the history
  • Loading branch information
klobuczek committed Feb 18, 2020
1 parent 38ade45 commit ff4a0f0
Show file tree
Hide file tree
Showing 256 changed files with 1,326 additions and 1,504 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rake'
require 'bundler/gem_tasks'
require 'neo4j/rake_tasks'
require 'active_graph/rake_tasks'
# load 'neo4j/tasks/migration.rake'

desc 'Generate YARD documentation'
Expand Down
6 changes: 3 additions & 3 deletions config/neo4j/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#id_property_type: :auto
#id_property_type_value: :uuid

# Example, (probably more useful directly on Neo4j::ActiveNode classes instead as a global configuration)
# Example, (probably more useful directly on ActiveGraph::ActiveNode classes instead as a global configuration)
#id_property: title_id
#id_property_type: :on
#id_property_type_value: :some_method
Expand All @@ -20,14 +20,14 @@
identity_map: false

# TODO
# When using the Neo4j::Model you can let neo4j automatically set timestamps when updating/creating nodes.
# When using the ActiveGraph::Model you can let neo4j automatically set timestamps when updating/creating nodes.
# If set to true neo4j.rb automatically timestamps create and update operations if the model has properties named created_at/created_on or updated_at/updated_on
# (similar to ActiveRecord).
timestamps: true

# Store a property on objects to cache their ActiveNode/ActiveRel class. It prevents each object load from requiring two database queries.
# Strings shorter than 44 characters are classified, so this will have almost no impact on disk footprint. See http://docs.neo4j.org/chunked/stable/short-strings.html.
# Alternatively, call class method Neo4j::ActiveNode:cache_class to set this on specific models.
# Alternatively, call class method ActiveGraph::ActiveNode:cache_class to set this on specific models.
# By default, this property is called _classname, set as symbol to override.
cache_class_names: true
# class_name_property: :_classname
Expand Down
54 changes: 27 additions & 27 deletions docs/ActiveNode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ ActiveNode

ActiveNode is the ActiveRecord replacement module for Rails. Its syntax should be familiar for ActiveRecord users but has some unique qualities.

To use ActiveNode, include Neo4j::ActiveNode in a class.
To use ActiveNode, include ActiveGraph::ActiveNode in a class.

.. code-block:: ruby
class Post
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
end
Properties
----------

All properties for Neo4j::ActiveNode objects must be declared (unlike neo4j-core nodes). Properties are declared using the property method which is the same as attribute from the active_attr gem.
All properties for ActiveGraph::ActiveNode objects must be declared (unlike neo4j-core nodes). Properties are declared using the property method which is the same as attribute from the active_attr gem.

Example:

.. code-block:: ruby
class Post
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
property :title
property :text, default: 'bla bla bla'
property :score, type: Integer, default: 0
Expand Down Expand Up @@ -56,7 +56,7 @@ Additionally you can change the name of a particular ``ActiveNode`` by using ``m
.. code-block:: ruby
class Post
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
self.mapped_label_name = 'BlogPost'
end
Expand All @@ -78,15 +78,15 @@ The class name maps directly to the label. In the following case both the class
.. code-block:: ruby
class Post
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
end
If you want to specify a different label for your class you can use ``mapped_label_name``:

.. code-block:: ruby
class Post
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
self.mapped_label_name = 'BlogPost'
end
Expand All @@ -96,7 +96,7 @@ If you would like to use multiple labels you can use class inheritance. In the
.. code-block:: ruby
class Post
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
end
class Article < Post
Expand All @@ -112,7 +112,7 @@ Pass a property name as a symbol to the serialize method if you want to save JSO
.. code-block:: ruby
class Student
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
property :links
Expand All @@ -136,7 +136,7 @@ You can declare special properties that maps an integer value in the database wi
.. code-block:: ruby
class Media
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
enum type: [:image, :video, :unknown]
end
Expand Down Expand Up @@ -193,7 +193,7 @@ By default, every ``enum`` property will require you to add an associated index
.. code-block:: ruby
class Media
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
enum type: [:image, :video, :unknown], _index: false
end
Expand All @@ -203,7 +203,7 @@ Sometimes it is desirable to have a default value for an ``enum`` property. To
.. code-block:: ruby
class Media
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
enum type: [:image, :video, :unknown], _default: :video
end
Expand All @@ -213,7 +213,7 @@ By default, enum setters are `case insensitive` (in the example below, ``Media.c
.. code-block:: ruby
class Media
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
enum type: [:image, :video, :unknown], _case_sensitive: false
end
Expand All @@ -229,7 +229,7 @@ Scopes in ``ActiveNode`` are a way of defining a subset of nodes for a particula
.. code-block:: ruby
class Person
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
scope :minors, -> { where(age: 0..17) }
end
Expand All @@ -239,7 +239,7 @@ This allows you chain a description of the defined set of nodes which can make y
.. code-block:: ruby
class Person
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
scope :eligible, -> { where_not(age: 0..17).where(completed_form: true) }
end
Expand All @@ -256,7 +256,7 @@ While that's useful in of itself, sometimes you want to be able to create more d
.. code-block:: ruby
class Person
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
scope :around_age_of, -> (age) { where(age: (age - 5..age + 5)) }
end
Expand All @@ -271,7 +271,7 @@ All of the examples so far have used the Ruby API for automatically generating C
.. code-block:: ruby
class Person
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
scope :non_teenagers, -> { where("#{identity}.age < 13 OR #{identity}.age >= 18") }
end
Expand All @@ -288,7 +288,7 @@ Finally, the ``scope`` method just gives us a convenient way of having a method
.. code-block:: ruby
class Person
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
def self.average_age
all(:person).pluck('avg(person.age)').first
Expand Down Expand Up @@ -330,11 +330,11 @@ created_at, updated_at
.. code-block:: ruby
class Blog
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
include Neo4j::Timestamps # will give model created_at and updated_at timestamps
include Neo4j::Timestamps::Created # will give model created_at timestamp
include Neo4j::Timestamps::Updated # will give model updated_at timestamp
include ActiveGraph::Timestamps # will give model created_at and updated_at timestamps
include ActiveGraph::Timestamps::Created # will give model created_at timestamp
include ActiveGraph::Timestamps::Updated # will give model updated_at timestamp
end
Validation
Expand All @@ -358,19 +358,19 @@ Associations
.. code-block:: ruby
class Post
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
has_many :in, :comments, origin: :post
has_one :out, :author, type: :author, model_class: :Person
end
class Comment
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
has_one :out, :post, type: :post
has_one :out, :author, type: :author, model_class: :Person
end
class Person
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
has_many :in, :posts, origin: :author
has_many :in, :comments, origin: :author
Expand Down Expand Up @@ -437,7 +437,7 @@ This is done by setting ``model_class: false`` or ``model_class: [:ModelOne, :Mo
.. code-block:: ruby
class Person
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
# Match all incoming relationship types
has_many :in, :written_things, type: :WROTE, model_class: [:Post, :Comment]
Expand Down Expand Up @@ -484,7 +484,7 @@ Similar to ActiveRecord, you can specify four ``dependent`` options when declari
.. code-block:: ruby
class Route
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
has_many :out, :stops, type: :STOPPING_AT, dependent: :delete_orphans
end
Expand Down
20 changes: 10 additions & 10 deletions docs/ActiveRel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Setup

ActiveRel model definitions have three requirements:

* ``include Neo4j::ActiveRel``
* ``include ActiveGraph::ActiveRel``
* Call ``from_class`` with a symbol/string referring to an ``ActiveNode`` model or :any
* Call ``to_class`` with a symbol/string referring to an ``ActiveNode`` model or :any

Expand All @@ -30,7 +30,7 @@ See the note on from/to at the end of this page for additional information.
# app/models/enrolled_in.rb
class EnrolledIn
include Neo4j::ActiveRel
include ActiveGraph::ActiveRel
before_save :do_this
from_class :Student
Expand All @@ -54,14 +54,14 @@ See the note on from/to at the end of this page for additional information.
# Using the `ActiveRel` model in `ActiveNode` models:
# app/models/student.rb
class Student
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
has_many :out, :lessons, rel_class: :EnrolledIn
end
# app/models/lesson.rb
class Lesson
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
has_many :in, :students, rel_class: :EnrolledIn
end
Expand Down Expand Up @@ -106,7 +106,7 @@ Add the :rel_class option to an association with the name of an ActiveRel model.
.. code-block:: ruby
class Student
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
has_many :out, :lessons, rel_class: :EnrolledIn
end
Expand Down Expand Up @@ -154,9 +154,9 @@ Once a relationship has been wrapped, you can access the related nodes using fro
lesson = Lesson.first
rel = EnrolledIn.create(from_node: student, to_node: lesson, since: 2014)
rel.from_node
=> #<Neo4j::ActiveRel::RelatedNode:0x00000104589d78 @node=#<Student property: 'value'>>
=> #<ActiveGraph::ActiveRel::RelatedNode:0x00000104589d78 @node=#<Student property: 'value'>>
rel.to_node
=> #<Neo4j::ActiveRel::RelatedNode:0x00000104589d50 @node=#<Lesson property: 'value'>>
=> #<ActiveGraph::ActiveRel::RelatedNode:0x00000104589d50 @node=#<Lesson property: 'value'>>
As you can see, this returns objects of type RelatedNode which delegate to the nodes. This allows for lazy loading when a relationship is returned in the future: the nodes are not loaded until you interact with them, which is beneficial with something like each_with_rel where you already have access to the nodes and do not want superfluous calls to the server.

Expand All @@ -171,7 +171,7 @@ ActiveRel really shines when you have multiple associations that share a relatio
.. code-block:: ruby
class User
include Neo4j::ActiveNode
include ActiveGraph::ActiveNode
property :managed_stats, type: Integer #store the number of managed objects to improve performance
has_many :out, :managed_lessons, model_class: :Lesson, rel_class: :ManagedRel
Expand All @@ -186,7 +186,7 @@ ActiveRel really shines when you have multiple associations that share a relatio
end
class ManagedRel
include Neo4j::ActiveRel
include ActiveGraph::ActiveRel
after_create :update_user_stats
validate :manageable_object
from_class :User
Expand Down Expand Up @@ -220,4 +220,4 @@ Additional methods
Regarding: from and to
----------------------

``:from_node``, ``:to_node``, ``:from_class``, and ``:to_class`` all have aliases using ``start`` and ``end``: ``:start_class``, ``:end_class``, ``:start_node``, ``:end_node``, ``:start_node=``, ``:end_node=``. This maintains consistency with elements of the Neo4j::Core API while offering what may be more natural options for Rails users.
``:from_node``, ``:to_node``, ``:from_class``, and ``:to_class`` all have aliases using ``start`` and ``end``: ``:start_class``, ``:end_class``, ``:start_node``, ``:end_node``, ``:start_node=``, ``:end_node=``. This maintains consistency with elements of the ActiveGraph::Core API while offering what may be more natural options for Rails users.
14 changes: 7 additions & 7 deletions docs/Configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ In either ``config/application.rb`` or one of the environment configurations (e.
Other Ruby apps
~~~~~~~~~~~~~~~

You can set configuration variables directly in the Neo4j configuration class like so: ``Neo4j::Config[:variable_name] = value`` where **variable_name** and **value** are as described below.
You can set configuration variables directly in the Neo4j configuration class like so: ``ActiveGraph::Config[:variable_name] = value`` where **variable_name** and **value** are as described below.

Variables
~~~~~~~~~
Expand Down Expand Up @@ -75,7 +75,7 @@ Variables
**skip_migration_check**
**Default:** ``false``

Prevents the ``neo4j`` gem from raising ``Neo4j::PendingMigrationError`` in web requests when migrations haven't been run. For environments (like testing) where you need to use the ``neo4j:schema:load`` rake task to build the database instead of migrations. Automatically set to ``true`` in Rails test environments by default
Prevents the ``neo4j`` gem from raising ``ActiveGraph::PendingMigrationError`` in web requests when migrations haven't been run. For environments (like testing) where you need to use the ``neo4j:schema:load`` rake task to build the database instead of migrations. Automatically set to ``true`` in Rails test environments by default

.. _configuration-class_name_property:

Expand Down Expand Up @@ -113,7 +113,7 @@ The ``neo4j-core`` gem instruments a handful of events so that users can subscri

.. code-block:: ruby
Neo4j::Core::CypherSession::Adaptors::Base.subscribe_to_query do |message|
ActiveGraph::Core::CypherSession::Adaptors::Base.subscribe_to_query do |message|
puts message
end
Expand All @@ -131,15 +131,15 @@ The argument to the block (``message`` in this case) will be an ANSI formatted s
All methods and their corresponding events:

**Neo4j::Core::CypherSession::Adaptors::Base.subscribe_to_query**
**ActiveGraph::Core::CypherSession::Adaptors::Base.subscribe_to_query**
**neo4j.core.cypher_query**

**Neo4j::Core::CypherSession::Adaptors::HTTP.subscribe_to_request**
**ActiveGraph::Core::CypherSession::Adaptors::HTTP.subscribe_to_request**
**neo4j.core.http.request**

**Neo4j::Core::CypherSession::Adaptors::Bolt.subscribe_to_request**
**ActiveGraph::Core::CypherSession::Adaptors::Bolt.subscribe_to_request**
**neo4j.core.bolt.request**

**Neo4j::Core::CypherSession::Adaptors::Embedded.subscribe_to_transaction**
**ActiveGraph::Core::CypherSession::Adaptors::Embedded.subscribe_to_transaction**
**neo4j.core.embedded.transaction**

2 changes: 1 addition & 1 deletion docs/Introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ neo4j-core
Provides low-level connectivity, transactions, and response object wrapping. Includes ``Query`` class for generating Cypher queries with Ruby method chaining.

Model
A Ruby class including either the ``Neo4j::ActiveNode`` module (for modeling nodes) or the ``Neo4j::ActiveRel`` module (for modeling relationships) from the ``neo4j`` gem. These modules give classes the ability to define properties, associations, validations, and callbacks
A Ruby class including either the ``ActiveGraph::ActiveNode`` module (for modeling nodes) or the ``ActiveGraph::ActiveRel`` module (for modeling relationships) from the ``neo4j`` gem. These modules give classes the ability to define properties, associations, validations, and callbacks

Association
Defined on an ``ActiveNode`` model. Defines either a ``has_one`` or ``has_many`` relationship to a model. A higher level abstraction of a **Relationship**
Expand Down
Loading

0 comments on commit ff4a0f0

Please sign in to comment.