Module: ActiveGraph::Node

Extended by:
ActiveSupport::Concern
Includes:
Callbacks, Dependent, DependentCallbacks, Enum, HasN, IdProperty, Initialize, Labels, Persistence, Property, Query, Reflection, Rels, Scope, Unpersisted, Validations, Shared, Shared::Identity, Shared::Marshal, Shared::PermittedAttributes, Shared::SerializedProperties, Transactions
Included in:
Migrations::SchemaMigration
Defined in:
lib/active_graph/node.rb,
lib/active_graph/node/enum.rb,
lib/active_graph/node/rels.rb,
lib/active_graph/node/has_n.rb,
lib/active_graph/node/query.rb,
lib/active_graph/node/scope.rb,
lib/active_graph/node/labels.rb,
lib/active_graph/node/property.rb,
lib/active_graph/node/wrapping.rb,
lib/active_graph/node/callbacks.rb,
lib/active_graph/node/dependent.rb,
lib/active_graph/node/reflection.rb,
lib/active_graph/node/id_property.rb,
lib/active_graph/node/orm_adapter.rb,
lib/active_graph/node/persistence.rb,
lib/active_graph/node/unpersisted.rb,
lib/active_graph/node/validations.rb,
lib/active_graph/node/query_methods.rb,
lib/active_graph/node/has_n/association.rb,
lib/active_graph/node/query/query_proxy.rb,
lib/active_graph/node/dependent_callbacks.rb,
lib/active_graph/node/node_list_formatter.rb,
lib/active_graph/node/query/query_proxy/link.rb,
lib/active_graph/node/query/query_proxy_methods.rb,
lib/active_graph/node/query/query_proxy_enumerable.rb,
lib/active_graph/node/dependent/association_methods.rb,
lib/active_graph/node/dependent/query_proxy_methods.rb,
lib/active_graph/node/query/query_proxy_eager_loading.rb,
lib/active_graph/node/has_n/association_cypher_methods.rb,
lib/active_graph/node/query/query_proxy_find_in_batches.rb,
lib/active_graph/node/query/query_proxy_methods_of_mass_updating.rb,
lib/active_graph/node/query/query_proxy_eager_loading/association_tree.rb

Overview

Makes Neo4j nodes and relationships behave like ActiveRecord objects. By including this module in your class it will create a mapping for the node to your ruby class by using a Neo4j Label with the same name as the class. When the node is loaded from the database it will check if there is a ruby class for the labels it has. If there Ruby class with the same name as the label then the Neo4j node will be wrapped in a new object of that class.

ClassMethods

Examples:

Create a Ruby wrapper for a Neo4j Node

class Company
   include ActiveGraph::Node
   property :name
end
company = Company.new
company.name = 'My Company AB'
Company.save

Defined Under Namespace

Modules: Callbacks, ClassMethods, Dependent, DependentCallbacks, Enum, HasN, IdProperty, Initialize, Labels, Persistence, Property, Query, QueryMethods, Reflection, Rels, Scope, Unpersisted, Validations, Wrapping Classes: NodeListFormatter, OrmAdapter

Constant Summary collapse

MARSHAL_INSTANCE_VARIABLES =
[:@attributes, :@_persisted_obj, :@default_property_value]
LOADED_CLASSES =
[]

Constants included from Labels

Labels::MODELS_FOR_LABELS_CACHE, Labels::WRAPPED_CLASSES

Constants included from Labels::Reloading

Labels::Reloading::MODELS_TO_RELOAD

Constants included from Shared::Property

Shared::Property::NEO4J_DRIVER_DATA_TYPES

Constants included from Shared::Attributes

Shared::Attributes::ATTRIBUTES_METHOD_PATTERNS, Shared::Attributes::DEPRECATED_OBJECT_METHODS

Instance Attribute Summary

Attributes included from Dependent

#called_by

Attributes included from Shared::Property

#_persisted_obj

Attributes included from IdProperty::Accessor

#default_property_value

Attributes included from Initialize

#called_by

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DependentCallbacks

#callbacks_from_relationship, #dependent_delete_callback, #dependent_delete_orphans_callback, #dependent_destroy_callback, #dependent_destroy_orphans_callback

Methods included from Shared::PermittedAttributes

#attributes=, #process_attributes

Methods included from Dependent

#dependent_children

Methods included from HasN

#association_proxy, #association_proxy_cache, #association_proxy_cache_fetch, #association_proxy_hash, #association_query_proxy, #delete_has_one_rel!, #delete_reverse_has_one_core_rel, #delete_reverse_has_one_relationship, #relationship_corresponding_rel, #reverse_association

Methods included from Unpersisted

#clear_deferred_nodes_for_association, #defer_create, #deferred_create_cache, #deferred_nodes_for_association, #pending_deferred_creations?

Methods included from Rels

#_rels_delegator

Methods included from Labels

_wrapped_classes, #add_labels, add_wrapped_class, clear_wrapped_models, #labels, model_for_labels, #remove_labels

Methods included from Labels::Reloading

reload_models!

Methods included from Query

#as, #query_as

Methods included from Shared::Callbacks

#conditional_callback, #destroy, #touch

Methods included from Validations

#valid?

Methods included from Shared::Validations

#read_attribute_for_validation, #save, #valid?

Methods included from Persistence

#_create_node, #concurrent_increment!, #create_model, #labels_for_create, #save, #save!

Methods included from Shared::Persistence

#apply_default_values, #cache_key, #concurrent_increment!, #create_or_update, #destroy, #destroyed?, #exist?, #freeze, #frozen?, #increment, #increment!, #inject_primary_key!, #new_record?, #persisted?, #props, #props_for_create, #props_for_persistence, #props_for_update, #reload, #reload_from_database, #skip_update?, #touch, #update, #update!, #update_attribute, #update_attribute!, #update_db_properties, #update_db_property, #update_model

Methods included from Shared::Property

#inject_defaults!, #inspect, #mutations_from_database, #read_attribute, #reload_properties!, #send_props, #undeclared_properties=

Methods included from Shared::TypecastedAttributes

#attribute_before_type_cast

Methods included from Shared::Attributes

#==, #attributes, #query_attribute, #write_attribute

Methods included from Shared::MassAssignment

#add_undeclared_property, #assign_attributes, #attributes=

Methods included from Shared::SerializedProperties

#serializable_hash, #serialized_properties

Methods included from IdProperty::Accessor

#default_properties, #default_properties=, #default_property, #default_property_key

Methods included from Initialize

#init_on_load, #init_on_reload

Methods included from Shared::Initialize

#wrapper

Methods included from Shared::Marshal

#marshal_dump, #marshal_load

Methods included from Shared::Identity

#==, #element_id, #hash, #id, #to_key

Methods included from Shared

#declared_properties, #neo4j_query

Class Method Details

.loaded_classesObject



64
65
66
# File 'lib/active_graph/node.rb', line 64

def self.loaded_classes
  LOADED_CLASSES
end

Instance Method Details

#initialize(args = nil) ⇒ Object



51
52
53
54
55
56
# File 'lib/active_graph/node.rb', line 51

def initialize(args = nil)
  self.class.ensure_id_property_info! # So that we make sure all objects have an id_property

  args = sanitize_input_parameters(args)
  super(args)
end

#neo4j_objObject



58
59
60
# File 'lib/active_graph/node.rb', line 58

def neo4j_obj
  _persisted_obj || fail('Tried to access native neo4j object on a non persisted object')
end