Sha256: fded1f0b57124d6e8079c7cc6079237ec14c27f85a3f9cf868d20b63b02c6e48
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
module Neo4j # Makes Neo4j Relationships more or less act like ActiveRecord objects. # See documentation at https://github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3AActiveRel module ActiveRel extend ActiveSupport::Concern include Neo4j::Shared include Neo4j::ActiveRel::Initialize include Neo4j::Shared::Identity include Neo4j::Shared::SerializedProperties include Neo4j::ActiveRel::Property include Neo4j::ActiveRel::Persistence include Neo4j::ActiveRel::Validations include Neo4j::ActiveRel::Callbacks include Neo4j::ActiveRel::Query include Neo4j::ActiveRel::Types class FrozenRelError < StandardError; end def initialize(from_node = nil, to_node = nil, args = nil) load_nodes(node_or_nil(from_node), node_or_nil(to_node)) super(hash_or_nil(from_node, args)) end 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 def neo4j_obj _persisted_obj || fail('Tried to access native neo4j object on a non persisted object') end included do include Neo4j::Timestamps if Neo4j::Config[:record_timestamps] def self.inherited(other) super end end ActiveSupport.run_load_hooks(:active_rel, self) private def node_or_nil(node) node.is_a?(Neo4j::ActiveNode) || node.is_a?(Integer) ? node : nil end def hash_or_nil(node_or_hash, hash_or_nil) node_or_hash.is_a?(Hash) ? node_or_hash : hash_or_nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
neo4j-6.0.0.alpha.11 | lib/neo4j/active_rel.rb |