Module: ActiveGraph::Node::DependentCallbacks
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActiveGraph::Node
- Defined in:
- lib/active_graph/node/dependent_callbacks.rb
Instance Method Summary collapse
- #callbacks_from_relationship(relationship, direction, other_node) ⇒ Object
- #dependent_delete_callback(association, ids) ⇒ Object
- #dependent_delete_orphans_callback(association, ids) ⇒ Object
- #dependent_destroy_callback(association, ids) ⇒ Object
- #dependent_destroy_orphans_callback(association, ids) ⇒ Object
Instance Method Details
#callbacks_from_relationship(relationship, direction, other_node) ⇒ Object
25 26 27 28 |
# File 'lib/active_graph/node/dependent_callbacks.rb', line 25 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 |
#dependent_delete_callback(association, ids) ⇒ Object
6 7 8 |
# File 'lib/active_graph/node/dependent_callbacks.rb', line 6 def dependent_delete_callback(association, ids) association_query_proxy(association.name).where(id: ids).delete_all end |
#dependent_delete_orphans_callback(association, ids) ⇒ Object
10 11 12 13 |
# File 'lib/active_graph/node/dependent_callbacks.rb', line 10 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 |
#dependent_destroy_callback(association, ids) ⇒ Object
15 16 17 18 |
# File 'lib/active_graph/node/dependent_callbacks.rb', line 15 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 |
#dependent_destroy_orphans_callback(association, ids) ⇒ Object
20 21 22 23 |
# File 'lib/active_graph/node/dependent_callbacks.rb', line 20 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 |