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

Version Path
activegraph-12.0.0.beta.5 lib/active_graph/node/dependent_callbacks.rb
activegraph-12.0.0.beta.4 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.5.0.beta.3 lib/active_graph/node/dependent_callbacks.rb
activegraph-12.0.0.beta.3 lib/active_graph/node/dependent_callbacks.rb
activegraph-12.0.0.beta.2 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.5.0.beta.2 lib/active_graph/node/dependent_callbacks.rb
activegraph-12.0.0.beta.1 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.5.0.beta.1 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.5.0.alpha.1 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.4.0 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.3.1 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.3.0 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.2.0 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.1.0 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.1.0.beta.1 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.1.0.alpha.4 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.1.0.alpha.3 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.1.0.alpha.2 lib/active_graph/node/dependent_callbacks.rb
activegraph-11.1.0.alpha.1 lib/active_graph/node/dependent_callbacks.rb
activegraph-10.2.0.beta.1 lib/active_graph/node/dependent_callbacks.rb