Sha256: a61c4ff1f8f2fd5e99c248bad32df2a5562a0668e08d0faa005ac0cc92e1ad31
Contents?: true
Size: 1.23 KB
Versions: 43
Compression:
Stored size: 1.23 KB
Contents
module ActiveGraph module Node module DependentCallbacks extend ActiveSupport::Concern def dependent_delete_callback(association, ids) association_query_proxy(association.name).where(id: ids).delete_all end def dependent_delete_orphans_callback(association, ids) unique_query = as(:self).unique_nodes(association, :self, :n, :other_rel, ids) unique_query.query.optional_match('(n)-[r]-()').delete(:n, :r).exec if unique_query end def dependent_destroy_callback(association, ids) unique_query = association_query_proxy(association.name).where(id: ids) unique_query.each_for_destruction(self, &:destroy) if unique_query end def dependent_destroy_orphans_callback(association, ids) unique_query = as(:self).unique_nodes(association, :self, :n, :other_rel, ids) unique_query.each_for_destruction(self, &:destroy) if unique_query end def callbacks_from_relationship(relationship, direction, other_node) rel = relationship_corresponding_rel(relationship, direction, other_node.class).try(:last) public_send("dependent_#{rel.dependent}_callback", rel, [other_node.id]) if rel && rel.dependent end end end end
Version data entries
43 entries across 43 versions & 1 rubygems