Module: ActiveGraph::Relationship

Extended by:
ActiveSupport::Concern
Includes:
Callbacks, Initialize, Persistence, Property, Query, Types, Validations, Shared, Shared::Enum, Shared::Identity, Shared::Marshal, Shared::PermittedAttributes, Shared::SerializedProperties, Transactions
Defined in:
lib/active_graph/relationship.rb,
lib/active_graph/relationship/query.rb,
lib/active_graph/relationship/types.rb,
lib/active_graph/relationship/property.rb,
lib/active_graph/relationship/callbacks.rb,
lib/active_graph/relationship/initialize.rb,
lib/active_graph/relationship/persistence.rb,
lib/active_graph/relationship/validations.rb,
lib/active_graph/relationship/related_node.rb

Overview

Makes Neo4j Relationships more or less act like ActiveRecord objects. See documentation at github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3AActiveRel

Defined Under Namespace

Modules: Callbacks, Initialize, Persistence, Property, Query, Types, Validations Classes: FrozenRelError, RelatedNode

Constant Summary collapse

MARSHAL_INSTANCE_VARIABLES =
[:@attributes, :@type, :@_persisted_obj]

Constants included from Types

Types::WRAPPED_CLASSES

Constants included from Shared::Property

Shared::Property::NEO4J_DRIVER_DATA_TYPES

Constants included from Shared::Attributes

Shared::Attributes::DEPRECATED_OBJECT_METHODS

Instance Attribute Summary

Attributes included from Shared::Property

#_persisted_obj

Instance Method Summary collapse

Methods included from Shared::PermittedAttributes

#attributes=, #process_attributes

Methods included from Callbacks

#destroy, #save

Methods included from Shared::Callbacks

#conditional_callback, #destroy, #touch

Methods included from Shared::Validations

#read_attribute_for_validation, #save, #valid?

Methods included from Persistence

#concurrent_increment!, #create_method, #create_model, #cypher_identifier, #delete_has_one_rel, #from_node_identifier, #from_node_identifier=, #query_as, #save, #save!, #to_node_identifier, #to_node_identifier=

Methods included from Shared::Persistence

#apply_default_values, #cache_key, #concurrent_increment!, #create_or_update, #destroy, #destroyed?, #exist?, #freeze, #frozen?, #increment, #increment!, #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 Property

#creates_unique_option, #type

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 Shared::Marshal

#marshal_dump, #marshal_load

Methods included from Shared::Identity

#==, #hash, #id, #neo_id, #to_key

Methods included from Initialize

#init_on_load, #init_on_reload

Methods included from Shared::Initialize

#wrapper

Methods included from Shared

#declared_properties, #neo4j_query

Instance Method Details

#initialize(from_node = nil, to_node = nil, args = nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/active_graph/relationship.rb', line 26

def initialize(from_node = nil, to_node = nil, args = nil)
  load_nodes(node_or_nil(from_node), node_or_nil(to_node))
  resolved_args = hash_or_nil(from_node, args)
  symbol_args = sanitize_input_parameters(resolved_args)
  super(symbol_args)
end

#neo4j_objObject



41
42
43
# File 'lib/active_graph/relationship.rb', line 41

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

#node_cypher_representation(node) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/active_graph/relationship.rb', line 33

def node_cypher_representation(node)
  node_class = node.class
  id_name = node_class.id_property_name
  labels = ':' + node_class.mapped_label_names.join(':')

  "(#{labels} {#{id_name}: #{node.id.inspect}})"
end